Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when closing HTML tags inside Jinja2 if statements #46

Open
christopherpickering opened this issue Dec 28, 2020 · 2 comments
Open
Labels
bug Something isn't working
Milestone

Comments

@christopherpickering
Copy link

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!

@christopherpickering christopherpickering added the bug Something isn't working label Dec 28, 2020
@christopherpickering
Copy link
Author

I see there is a comment in the code for a similar situation -
https://github.com/thibaudcolas/curlylint/blob/main/curlylint/parse.py#L549

@thibaudcolas thibaudcolas added this to the v0.14.0 milestone Apr 25, 2021
@jkevingutierrez
Copy link

jkevingutierrez commented Mar 3, 2023

Having the same issue with the opening tags. For example:

{% if is_div %}
<div>
{% endif %}

Test

</div>
6:1	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 6:1	parse_error

Probably that's not the best example, but something like

{% if is_div %}
<div>
{% endif %}

Test

{% if is_div %}
</div>
{% endif %}

will also fail

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants