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

Conditional syntaxes cause an ERROR(?!) if condition is False #1418

Open
guillemrbaiges opened this issue Oct 26, 2022 · 0 comments
Open

Conditional syntaxes cause an ERROR(?!) if condition is False #1418

guillemrbaiges opened this issue Oct 26, 2022 · 0 comments

Comments

@guillemrbaiges
Copy link

I'm migrating a former Copier (Jinja2) template into Nunjucks. So far I have focused on the following conditionals:

src/
     {% if values.include_deployment %}main.py{% endif %}
     {% if values.include_deployment %}pipeline.py{% endif %}
     {% if not values.include_deployment %}pipeline.py{% endif %}

All the issues I have found while debugging this simple use case:

  1. Without modifying the code above, this example outcomes the following error:
    EISDIR: illegal operation on a directory, open '/tmp/0eb043fb-1a7a-4c8c-b226-8b5fd818a662/src'
  2. If the not is deleted and values.include_deployment == true, then templating this snippet works as expected
  3. If the not is deleted and values.include_deployment == false, then templating this snippet fails with:
    Error: EISDIR: illegal operation on a directory, open '/tmp/f9cd3cf9-b493-4af4-8f9a-8101ba5c3fb3/src'
  4. If I add the not to the three conditionals and values.include_deployment == false, then templating this snippet works as expected
  5. If I delete the not and use ... == false the error is the same (EISDIR)
  6. If I change the not for ! it complains about the later being an unrecognized token

Based on your FAQs this should not be a compatibility issue between Jinja2 and Nunjucks. This syntax is the same in both Python and Javascript and, honestly, this is one of the most basic functionalities you expect in a templating engine. What's happening here?

@guillemrbaiges guillemrbaiges changed the title Conditional syntaxes FAIL(?!) if condition is False Conditional syntaxes cause an ERROR(?!) if condition is False Oct 26, 2022
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

1 participant