Skip to content

Crash when closing HTML tags inside Jinja2 if statements #46

@christopherpickering

Description

@christopherpickering

Thanks for the neat tool!

I've run into an issue with jinja2 when close a html tag inside of a jinja2 if statement. Something simple like this -

<!DOCTYPE HTML>
<div>
    {% if a == 1 %}
        </div>
        <h1>a</h1>
        <div>
    {% endif %}
</div>

will produce this error:

test.html 3:9 Parse error: expected one of '[:a-zA-Z]', 'animate', 'animateMotion', 'animateTransform', 'area', 'base', 'br', 'circle', 'col', 'ellipse', 'embed', 'feBlend', 'feColorMatrix', 'feComposite', 'feConvolveMatrix', 'feDisplacementMap', 'feDistantLight', 'feDropShadow', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpotLight', 'feTile', 'feTurbulence', 'hr', 'image', 'img', 'input', 'line', 'link', 'meta', 'mpath', 'param', 'path', 'polygon', 'polyline', 'rect', 'script', 'set', 'source', 'stop', 'style', 'track', 'use', 'wbr', '{#', '{%', '{{' at 3:9   parse_error

I'm on a Mac using python 3.9 w/ the latest version of curlylint.

curlylint test.html

The general syntax validation seems to work well up until this step. Possible could the template tags be stripped out for this particular test? Or allow close / open tags out of sequence inside an if statement?

Or ideas for a better way to write jinja are also welcome :)
Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions