Templito ======= The Back end Templating language behind the Siter - a static website generator. What makes templito different ======================== Templito templates largely resemble those of handlebars and Go templates, but they have a few standout features. * Language * Multiple parameters to templates * Functions can be run on the result of a block * Whitespace can be escaped * Rust * Template functions can be closures, so they can have data attached to the functions. * Template and Function Managers are separate from the template and can be switched in and out generically. Examples ========= Basic structure of a template ```html {{let title = "Page"}}\
{{$k}} = {{$v}}
{{/for}}\ {{/if}}\ ``` Using Blocks ```html {{@md}} Markdown ============================ Everthing between an '@{{$v}}
{{/for}} ``` will output: ```htmlapple
cat
sandwhich
``` Depending on the security situation, you can opt in or out to allowing "exec" functions. ("exec" is not included in the defaults) ```html {{for k v in split (exec "cat" "path/to/file") "\n"}}{{$k}} = {{$v}}
{{/for}} ``` ## Control Flow * "let" Create variables (Used in rest of docs) {{let x=3;y=9;list=["fish","dog"]}} * "export" Export variables can be returned to the calling program in a map of exports * "if","elif" and "else" Control flow, only resolve the contents if the contition is met otherwise look at the elif and elses {{if gt $x 3}}{{$x}}{{elif gt $y 3}}{{$y}}{{else}}Something else{{/if}} //output: 9 * "return" return a value instead of the main string * "for" Loop over a list or value. This requires the index, and value be named (eg k and v) {{for k v in $list}}list at {{$k}} equals {{$v}};{{/for}} //output: list at 0 equals fish;list at 1 equals dog; * "switch" and "case" choose one option based on the value matched by a pattern {{- switch $list -}} {{- case [_,]}}List with second element {{$b}} {{- case {fish: