#macro sayHello() Hello. #end #if (true) #sayHello() #endThis will print a single line of text, consisting of Hello. followed by a newline.
#macro sayHello() Hello. #end #if (true) The greeting is: #sayHello() #endThis will print:
The greeting is: Hello.Note that since the call to #sayHello() does not fall at the beginning of a line, the space after the colon is preserved.
#if (showGreeting) ${greeting} #* Display the greeting *# #endThe rule for comments is therefore slightly different in one respect: whitespace preceding a comment is always ignored (even if it doesn't start at the beginning of a line), and a newline following a comment is ignored. The above example will print the value of greeting, with no additional whitespace or newlines.
#if (true) yes\ #endThis will print yes with no newline.
#* comment *#Comments can be nested.
\${ \#Additional backslashes preceding an escape sequence are simply included in the output, as are backslashes not followed by ${ or #.
${expression}Adds the value of expression (which must evaluate to a scalar) to the output.
There #if (n == 1)is 1 file#else#are ${n} files#end#.
#foreach (name in expression)Evaluates expression as a list; iterates over the list, assigning each element in turn to name. Any previous value of name is temporarily hidden.template text#end
#if (expression)The #elseif and #else blocks are optional; any number of #elseif blocks may be used. You can write #else# instead of #else.template text#elseif (expression)template text#elsetemplate text#end
#set (name = expression)Assigns the value of expression to the variable name in one of the following places, in order of preference:
#var (name)Assigns the value of expression (or a null value if expression is not supplied), to the variable name in one of the following places, in order of preference:
#var (name = expression)
#include (expression)Interprets the string value of expression as the name of a template, and includes the contents of that template in the one currently being processed.
#macro macroname (paramname1, paramname2, ... paramnamen)Defines a macro called macroname that takes n parameters.template text#end
#macroname (param1, param2, ... paramn)Invokes the macro called macroname. If a macro is called with fewer parameters than were defined in the macro, the remaining parameters are set to null.
#open (expression)Interprets the string value of expression as the name of a template, and adds it to the list of templates in which macros will be searched for when invoked in the currently running template.
Operator Meaning Compatible Types ! unary not boolean values - subtraction, unary negation integers, floats + addition, string concatenation integers, floats, strings * multiplication integers, floats / division integers, floats % modulo integers, floats == equality scalars != inequality scalars < less than integers, floats, strings > greater than integers, floats, strings <= less than or equal to integers, floats, strings >= greater than or equal to integers, floats, strings && and boolean values || or boolean values . hash lookup with identifier as key hash on left, identifier on right [] hash lookup with string as key hash on left, string on right () function call function on left, comma-separated expressions in parentheses = assignment identifier on left, expression on right