templo
templo copied to clipboard
::use:: tag prints null
Hello.
The ::use::
tag prints null before printing the used template file.
Here is a code example:
The Index.hx file:
import php.Lib;
import templo.Loader;
class Index {
public static function main() {
Loader.BASE_DIR = "../tpl/";
Loader.TMP_DIR = "tmp/";
Loader.MACROS = null;
var template = new Loader("page.html");
var render = template.execute({});
Lib.print(render);
}
}
The page.html file:
::use 'base.html'::
Content
::end::
The base.html file:
<!DOCTYPE html>
<html>
<head>
<title>Title</title>
<meta charset="utf-8"/>
</head>
<body>
<h1>Title</h1>
::raw __content__::
</body>
</html>
The build.hxml file:
-main Index
-php www
-lib templo
And here is the output (there is an unwanted "null" before everything):
null<!DOCTYPE html>
<html>
<head>
<title>Title</title>
<meta charset="utf-8"/>
</head>
<body>
<h1>Title</h1>
Content
</body>
</html>
Thanks to fix this bug.
Hello. It seems there is a bufferCreate() call missing somewhere. If I change the includeTemplate() method to this:
class Loader {
//…
function includeTemplate( file : String, container : String, ctx : Dynamic ) {
var old_content = content;
content = bufferPop();
bufferCreate(); //Line added.
if( !OPTIMIZED )
compileTemplate(file);
untyped __call__("require", tmpFileId(file));
content = old_content;
}
//…
}
it does not print null anymore. However, I don't know if this change cause problems elsewhere. Do you know if it is the problem? Thanks to fix this problem.