rtts / djhtml

Django/Jinja template indenter
GNU General Public License v3.0
572 stars 32 forks source link

Incorrect parse when greater-than comparison in DTL-if inside HTML tag #20

Closed sjoerdjob closed 3 years ago

sjoerdjob commented 3 years ago
<!-- if with greater than inside tag -->
<div {% if foo > bar %} class="baz"{% endif %}>
    quux
</div>

The tokenizer seems to interpret <div {% foo > as the tag.

found closing “{% endif %}” on line 2 while expecting “</div>”
JaapJoris commented 3 years ago

In order to solve this, the tokenizer should make 2 passes over the source instead of just 1. In the first pass, only django template tags should be recognized, while in the second pass the mode-specific tags should be tokenized. This will require some refactoring. I'm on it!