Authored by weiqingting

control,interface,views

母 {{key}}
母 {{key2}}
母 {{> layout}}
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<h1>index {{key}}</h1>
<h1>index {{key2}}</h1>
<h1>layout {{>layout}}</h1>
</body>
</html>
... ...
子 {{key2}}
\ No newline at end of file
Layout {{key1}}
<h4>Layout 引用 {{> layout2 }}</h4>
\ No newline at end of file
... ...
Layout2 {{key2}}
\ No newline at end of file
... ...
... ... @@ -69,11 +69,15 @@ var __parsefile = function(fileKey,filePath,dataModel,callback){
}
var __parseLayout=function(form,str){
var me=this,cache=this.cache;
console.log(form+":"+str);
var layouts=str.match(/\{\{>[^}]*\}\}/g);
return str.replace(/\{\{>[^}]*\}\}/g,function($0){
var name=path.resolve(path.dirname(form),$0.match(/\{\{>\s*([^}]*)\s*\}\}/m)[1]+".html");
return fs.readFileSync(name,'utf8');
var name=path.resolve(path.dirname(form),$0.match(/\{\{>\s*([^}]*)\s*\}\}/m)[1].replace(/\s/g,'')+".html");
var html=fs.readFileSync(name,'utf8');
if(/\{\{>[^}]*\}\}/g.test(html)){
html=__parseLayout(name,html);
}
return html;
});
}
... ...