Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 6078c66235
Fetching contributors…

Cannot retrieve contributors at this time

66 lines (46 sloc) 1.378 kb
Advanced templating: illustrates defines and includes.
Include external snippet defined in a variable:
{{#def.externalsnippet}}
Load external template from a file:
{{#def.loadfile('/snippet.txt')}}
Load external template from a file and cache in a variable:
{{#def['snippet.txt'] || (def['snippet.txt'] = def.loadfile('/snippet.txt'))}}
Use cached file again:
{{#def['snippet.txt']}}
Here is a def block that will be used later. This snippet can be referenced from external templates too:
{{##def.snippet1:
Some snippet that will be included {{#def.a}} later {{=it.f1}}
#}}
First use of snippet1:
{{#def.snippet1}}
Second use of snippet1:
{{#def.snippet1}}
Include snippet1 if true:
{{# true && def.snippet1 }}
Runtime and Compile time evaluation used together:
{{= it.f3 + {{#def.a + def.b}} }}
Include xyz or insert 'not found':
{{#def.xyz || 'not found'}}
Set xyz to 1 and exclude result from output:
{{##def.xyz=1#}} is identical to {{#(def.xyz=1) && ""}}
Compare xyz to 1, show 'xyz is not 1' if false:
{{#def.xyz === 1 || 'xyz is not 1'}}
{{ if ({{#!def.abc}}) { }}
{{#def.abc}} is falsy
{{ } }}
{{ if ({{#def.xyz === 1}}) { }}
if(true) block
{{ } }}
{{##def.fntest = function() {
return "Function test worked!";
}
#}}
{{#def.fntest()}}
Conditionals:
{{? !it.altEmail }}
<p>
second email: {{= it.altEmail }}
</p>
{{?? true }}
else case worked
{{?}}
Jump to Line
Something went wrong with that request. Please try again.