How to use HTML.Template
The <tmpl_include> tag
The <tmpl_include> tag is the next simplest tag after <tmpl_var>, however, it will not do what you expect it to do inside a <tmpl_if>
<tmpl_include> is used to include the contents of another template within this template, at the position of the tag. Processing then continues, as if the included template were always a part of the current template.
Modify the loop example to look like this:
<tmpl_loop employee_info> <tmpl_include body.tmpl> </tmpl_loop>
And create body.tmpl to look like this:
<p> Name: <tmpl_var name><br> Job: <tmpl_var job><br> </p>
Run it with the same java source, and you should get the following output:
<p> Name: Philip<br> Job: programmer<br> </p> <p> Name: Bob<br> Job: Web designer<br> </p> <p> Name: John<br> Job: Manager<br> </p>
<tmpl_include> and <tmpl_if>
Since tmpl_include tags are evaluated when the template is being read from file, other tags have no effect on them. Therefore, the following code will include the body.tmpl regardless of whether display is true or false.
<tmpl_if display> <tmpl_include body.tmpl> </tmpl_if>
As of verion 0.0.8, HTML.Template.java supports setting the include depth using the max_includes constructor parameter. The default is 10 levels of includes.