Keats / tera

A template engine for Rust based on Jinja2/Django
http://keats.github.io/tera/
MIT License
3.36k stars 280 forks source link

Filter sections but set the result in a variable #904

Open piegamesde opened 4 months ago

piegamesde commented 4 months ago

Not sure how to best describe this, and I couldn't find anything matching in the documentation. But basically what I need is to create a larger string, and use the templating features for that. The documentation mentions "filter sections":

{% filter upper %}
    Hello
{% endfilter %}

and what I'd need would be something like

{% set upper %}
    Hello
{% endset %}

which stores Hello in the variable upper. The important bit is that I can then use all of the templating features inside it.

Not sure if there are other ways to achieve it

Keats commented 4 months ago

Well it's actually implemented exactly like that in v2: https://github.com/Keats/tera2/blob/master/src/tests/rendering_inputs/success/set_blocks.txt ;)