Trim whitespace in Jinja2


22/03/2019, 17:30

First and important to read Whitespace Control documentation and this answer in Stackoverflow.

Here are few examples:

{%- if page_title %} strips before start
{% if page_title -%} strips after start
{%- if page_title -%} strips before and after start

Note that opening and closing conditions threads separately:

{%- endif %} strips before end
{% endif -%}  strips after end
{%- endif -%}  strips before and after end


Комментарии