1👍
The hyphens have nothing to do with Django itself. My guess is that these should be used to hint the code formatted to format these properly.
The reason that this is likely is because if we look a the source code of the documentation [GitHub], we see:
{% raw %} ```html <div class="class1 {% if condition -%}class2{%- endif %}">content</div> ^ space here ``` {% endraw %}
The {% raw %}
and {% endraw %}
are used for the rendering engine of the documentation itself. Likely the hyphen is used to prevent the render engine from interpreting the template tags we want to show as just code, so to prevent that {% if condition %}
is interpreted itself.
But it looks like the formatted has done a bad job, and retained the hyphens, and thus the documentation shows some of the "mechanics" on how the documentation should be rendered.
0👍
This is Jinja2 templating syntax. The -
is part of controlling how it deals with whitespace.
https://jinja.palletsprojects.com/en/3.1.x/
From the docs:
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
- [Answered ]-Compare datetime with DateField for equivalency?
- [Answered ]-Merging tables from django-tables2 and dynamic models