String template
Variable substitution:
{{myobject.attribute}}
Code substitution:
{% for item in mylist do { %}
* {{item}}
{% } %}
var text = "{{hello}} {{world}}";
var result = std.format.substitute(text, variable: func (name) {
if name == "hello" then
return "world";
if name == "world" then
return "wo" + "rld"; // imagine a more cpu-expensive value
return "";
});
var text = "{% for i in items do { %} * {{prefix + i}} {% } %}";
var output = std.format.eval(text, {items: ["item 1", "item 2"]}, uses: ["std.io", "std.memory"], cwd: "/tmp");
stdout << output;
Edited by username-removed-133366