Advertisement

Your Ad could be here. I want to connect my readers to relavant ads. If you have a product targeted at developers, let's talk. [email protected]

Here's my thought on Template Designer Documentation — Jinja Documentation (3.0.x)


html code generated by my jinja templates generally look half garbage because of indents and whitespace all over the place. I just learned about these pesky Whitespace Control characters that can get rid of the whitespace added from templating.

You can also strip whitespace in templates by hand. If you add a minus sign (-) to the start or end of a block (e.g. a For tag), a comment, or a variable expression, the whitespaces before or after that block will be removed:


{% for item in seq -%}
    {{ item }}
{%- endfor %}

This post was a thought by Waylon Walker see all my thoughts at https://waylonwalker.com/thoughts