2
0
Laurent Bedubourg 19 жил өмнө
parent
commit
ad1f8aa71a

+ 5 - 1
std/mtwin/templo/Parser.hx

@@ -85,7 +85,11 @@ class Parser {
 
 		var mtUse = extractAttribute(xml, MT_USE);
 		if (mtUse != null){
-			var f = mtwin.templo.Template.fromFile(mtUse); // ensure template is parsed (beware of cycle)
+			// ensure template is parsed (beware of cycle)
+			if (!mtwin.templo.Template.compiledFiles.exists(mtUse)){
+				mtwin.templo.Template.compiledFiles.set(mtUse, true);
+				var f = mtwin.templo.Template.fromFile(mtUse); 
+			}
 			out.add("tmp = __ctx.get($hash(\"__content__\"));\n");
 			out.add("__out = new_output_buffer(__out);\n");
 			parseNode(xml);

+ 2 - 0
std/mtwin/templo/Template.hx

@@ -27,6 +27,7 @@ package mtwin.templo;
 
 class Template {
 
+	public static var compiledFiles : Hash<Bool> = new Hash();
 	public var execute : Dynamic -> String;
 
 	public function new( file:String ){
@@ -66,6 +67,7 @@ class Template {
 				return loadTemplate(binPath);
 			}
 		}
+		compiledFiles.set(path,true);
 		var content = neko.File.getContent(Loader.BASE_DIR+"/"+path);
 		return fromString(content, nekoId(path));
 	}