-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Description
Given the following Django template,
{% if has_sidebar %}
<div class="col10">
{% else %}
<div class="col12">
{% endif %}
<p>Main content</p>
</div>
{% if has_sidebar %}
<div class="col2">
<p>Sidebar</p>
</div>Jinjalint will produce the following parse error:
3:3: Parse error: expected one of 'autoescape', 'block', 'blocktrans', 'comment', 'endif', 'filter', 'for', 'if', 'ifchanged', 'ifequal', 'ifnotequal', 'not an intermediate Jinja tag name', 'spaceless', 'verbatim', 'with' at 2:3
This is quite a common pattern in templates, that's not the most readable for a small example like this but is usually used to limit repetition. Refactoring this to a more straightforward <div class="{% if has_sidebar %}col10{% else %}col12{% endif %}"> is possible in simple cases, but it might not always be desirable. It would be nice if jinjalint was able to parse this, understanding the conditional and the fact that in practice there will always be one and only one opening div.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels