]> WPIA git - gigi.git/blob - doc/TemplateSyntax.txt
add: import script for json.org
[gigi.git] / doc / TemplateSyntax.txt
1 A template is constructed from a charstream. Everything that is not in "<?" to "?>" will be outputted directly. Text in these markers will be interpreted is template scripting syntax. The following strings are valid:
2
3 General remarks:
4 - $variablename: a variablename matches the regex [a-zA-Z0-9_-]
5 Syntax:
6 - <?=$variablename?> will output "variablename".
7    if "variablename" is an Outputable output this thing recursively.
8    else turn it into a String (Object.toString()) and output it.
9
10 - <?=$!variablename?> will output the variable "variablename" but not HTML-escaped
11    
12 - <?=_This is free Text.?> will translate "This is free Text." into the users language, (escaped) and output it.
13         Text may not contain "?>".
14         If the text contains "$" or "!'" it is interpreted as "advanced replacement".
15            - ${variablename} is interpreted as "output this variable at this point"
16            - !'literal content' output "literal content" here and do not translate or escape. (literal content may not contain any of: {}'$   )
17         Then the whole text than also may not contain "{" and "}".
18
19 - <? if($variable) { ?> ... <? } ?>
20   Output/execute the text until "<? } ?>" only if $variable is Boolean.TRUE (<=> !Boolean.FALSE) or not null. 
21 - <? if(...) { ?> ... <? } else { ?> ... <? } ?>
22
23 - <? foreach($variable) { ?> ... <? } ?>
24   If $variable is an "IterableDataset"
25   Output/execute the text until "<? } ?>" repeated as $variable suggests. 
26   Special variables that $variable defines can be used in the inner text.
27  
28   
29 Adding a "\" before a newline will cause both the backslash and the newline get removed. This allows non-visible line-breaks in templates.
30 Note: Mail templates consist of a template for subject and a template for the body. Prolonging the subject-line with this feature is not possible.