tmpl_varYou can set default values for your template variables, which will be used if no value has been set through the setParam method.
<TMPL_VAR name="var_name" default="my value">
If var_name is set using setParam (or setParams), then it's value will be whatever it was set to, else it will be "my value" (without the quotes).
You can also "escape" certain strings. The following escape modes are possible.

tmpl_ifThe <tmpl_if> tag allows you to include or not include a block of the template based on the value of a given parameter name. If the parameter is given a value that is true, then the block is included in the output. If the value is false, then it is skipped.
The tmpl_if must be closed with a corresponding /tmpl_if, e.g.
<tmpl_if ...>
...
</tmpl_if>
Parameter values for conditions are Strings in java, and not boolean values, hence, what evaluates to true and false needs to be specifically defined.
As of now, the following values evaluate to false:
"" - the empty string
"0" - the string containing only the number zero
null - the null value

tmpl_elseWhile the if block allows us to display some output if a condition is true, we may also need to display content if the condition is false. This can be done by using the optional else branch of the if block.
tmpl_unless
This tag is the exact opposite of the <tmpl_if> tag. A <tmpl_unless> block is displayed if its control variable evaluates to false. If the control variable evaluates to true, then the else block, if any, is displayed instead.

tmpl_loopThe <tmpl_loop> tag is a bit more complicated than the other tags. It allows you to create a section of text that will be displayed repeatedly for every item in the loop control variable. Inside the <tmpl_loop>, you place <tmpl_var>s. The only loop used by the template exporter is 'cache_index', see example above.
Loop context variables
If you set loop_context_vars to true in your Template's constructor, then you will have access to five special variables in all your loops. These are:
__FIRST__ True for the first run of the loop, false otherwise
__LAST__ True for the last run of the loop, false otherwise
__ODD__ True for every other iteration of the loop - a loop starts at 1
__INNER__ True if both __FIRST__ and __LAST__ are false
__COUNTER__ Which iteration is currently on. Starts at 1

You may use these like any other <TMPL_VAR> inside your loop.

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