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

jinja2 lstrip_blocks behavior #892

Open OmarTawfik opened 6 months ago

OmarTawfik commented 6 months ago

lstrip_blocks: If this is set to True leading spaces and tabs are stripped from the start of a line to a block. Defaults to False. https://jinja.palletsprojects.com/en/3.1.x/api/

Code Example: https://ansiblemaster.wordpress.com/2016/07/29/jinja2-lstrip_blocks-to-manage-indentation/

It is very useful to be able to control/override indentation in for loops and if blocks, without having to dedent the template code, making it less readable. This is especially important for languages that indentation is actually semantically meaningful, like markdown or python.

I understand Tera doesn't support jinja2 environment variables, but I wonder if it is possible to support options like lstrip_blocks using another Tera-blessed way/using existing syntax?

Keats commented 6 months ago

We could probably add that to tera2?