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.

Examples

Basic structure of a template

```html {{let title = "Page"}}\

{{first $title "Default Title"}}

{{if .cat}}\ {{for k v in .cat}}\

{{$k}} = {{$v}}

{{/for}}\ {{/if}}\ ```

Using Blocks ```html {{@md}}

Markdown

Everthing between an '@' and '\func' tags will run the function on the result of the contents.

for example the because this code is within an '@md' block, the contents will be treated as markdown.

(Assuming the md function is included by the FuncManager)

Ranges like this will create a bullet point list of items:

{{for k v in .items}} * {{$v}} {{- /for}}

{{/md}} ```

In fact any string to string function can be used as an "@block"

But they are more powerful than that.

html {{@let lines}} apple cat sandwhich {{/let}}\ {{for k v in split $lines}} <p>{{$v}}</p> {{/for}} will output:

html <p>apple</p> <p>cat</p> <p>sandwhich</p>

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"}} <p>{{$k}} = {{$v}}</p> {{/for}}

Control Flow

Changelog

V 0.4.0

Keyword "as" now exists which could possibly break some previous functions of the same name. Can now use {{as val:pattern}}with pattern captures here{{/as}}

V 0.2.0

Breaking Change : Functions now require a description to make documentation much easier for users of the system.

Funcmanagers now also provide/require a method to provide those descriptions so they can be printed by any software that uses the system.