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>

And create body.tmpl to look like this:

Name: <tmpl_var name><br>
Job: <tmpl_var job><br>

Run it with the same java source, and you should get the following output:

Name: Philip<br>
Job: programmer<br>

Name: Bob<br>
Job: Web designer<br>

Name: John<br>
Job: Manager<br>

<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>

Recursive Includes

As of verion 0.0.8, supports setting the include depth using the max_includes constructor parameter. The default is 10 levels of includes.