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

Invalid Jinja2 syntax not detected (missing leading {) #29

Open
c-po opened this issue Apr 16, 2022 · 2 comments
Open

Invalid Jinja2 syntax not detected (missing leading {) #29

c-po opened this issue Apr 16, 2022 · 2 comments

Comments

@c-po
Copy link

c-po commented Apr 16, 2022

The following is not detected:

{% if foo is defined %}
    bar-option
% else %}
    baz-option
{% endif %}

The missing leading { is not found.

@c-po c-po changed the title Invalid Jinja2 syntax not detected Invalid Jinja2 syntax not detected (missing leading {) Apr 18, 2022
@ClausHolbechArista
Copy link
Collaborator

The j2lint cannot detect this case, since it is simply not jinja. It will just be interpreted as a regular string, so ignored by the linter. We could create a warning for closing tag (%}) with missing opening tag ({%) but the jinja2 engine accepts this and renders % else %} like any other string, so I am not sure if we want to enforce this.

@c-po
Copy link
Author

c-po commented Apr 19, 2022

A warning would probably be a good idea - and could be switched off like other linting rules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants