Open
Description
Appears to work in Python jinja2, and there's a Note that mentions it in this section in the docs.
https://jinja.palletsprojects.com/en/2.10.x/templates/#literals
Here's a template example that works in Python and crashes on "Load" today.
{% set foo = None %}
{% if foo != None %}
1
{% else %}
None
{% endif %}
{% set bar = 1 %}
{% if bar != None %}
1
{% else %}
None
{% endif %}
{% set baz = none %}
{% if baz != none %}
1
{% else %}
none
{% endif %}
{% set qux = 1 %}
{% if qux != none %}
1
{% else %}
none
{% endif %}
This code change seemed to do the trick for me and seems to produce the correct output and no longer crash.
diff --git a/jinja2cpp/src/expression_parser.cpp b/jinja2cpp/src/expression_parser.cpp
--- a/jinja2cpp/src/expression_parser.cpp
+++ b/jinja2cpp/src/expression_parser.cpp
@@ -326,6 +326,8 @@
return std::make_shared<ConstantExpression>(InternalValue(true));
case Token::False:
return std::make_shared<ConstantExpression>(InternalValue(false));
+ case Token::None:
+ return std::make_shared<ConstantExpression>(InternalValue(EmptyValue()));
case '(':
valueRef = ParseBracedExpressionOrTuple(lexer);
break;
Metadata
Metadata
Assignees
Labels
No labels