is a lightweight and efficient templating engine written in V. It provides a fast way to render templates with dynamic content. Simple as 1, 2, 3 — (1) load the
template
context
render
Features
- Simple to use API, lightweight and fast;
- Variables — with HTML escaping by default;
- Conditional sections;
- Nested context and iteration over arrays;
- Error handling.
Installation
Install the
V language
v install pastilhas.wustache
Usage
template := '{{greet}}, {{name}}. {{#admin}}You are admin.{{/admin}}'
obj := '{ "greet": "Hello", "name": "John", "admin": true }'
res := render(template, obj)!
println(res) // 'Hello, John. You are admin.'
Interpolation
Hello, {{name}}.
Welcome, {{user.name}}. You have {{user.unread}} messages.
<div id="login_form">
{{&login_form}}
</div>
Sections
{{#never_true}} This will never be seen! {{/never_true}}
{{#is_logged}} Welcome back! {{/is_logged}}
{{#items}}
{{$.name}}: {{$.price}}
{{/items}}
Repeats
content
- 0, if falsy value — false, empty string, 'false', '0', '0.0', empty array, empty map;
- 1, if truthy value — true, non-empty string, non-empty map;
- n, for n-sized array — each iteration, the value is mapped to
$
Inverted
{{^is_logged}}
{{&login_form}}
{{/is_logged}}
{{#is_logged}}
Hello, {{user.name}}!
{{/is_logged}}
Repeats
content
Mustache compatibility
Planned
- Variables
- Dotted names
- Implicit iterator (with modifications)
- Sections
- Inverted sections
- Partials
- Set delimiter
Not planned
- Lambdas
- Comments
- Dynamic partials
- Blocks
- Parents
- Dynamic parents
License
wustache
About
wustache is a lightweight and efficient templating engine written in V. It provides a fast way to render templates with dynamic content. Simple as 1, 2, 3 — (1) load the template, (2) write the context as JSON, and (3) execute render. It is safe by default, but you can make it less picky.