Comments (4)
Just to check my understanding, I confirmed that Jinja handles this as I would expect.
from jinjava.
I believe I've found the bug, and it's even more basic than the examples so far in this issue. The template {{ -10 }}
parses as -10
in Jinja and 10
in Jinjava.
The bug is coming from a feature of Jinjava (which, as expected, comes from Jinja) called whitespace control. In an expression or other block, you can add a dash at the beginning or end to control whether preceding or trailing whitespace on the line is trimmed. For example, the template {{- "foo" }}
would trim all leading whitespace on the line ahead of foo
.
The Jinja docs specify, "You must not add whitespace between the tag and the minus sign." However, the current Jinjava implementation allows whitespace in between the tag and the dash, so negative numbers at the start of expressions are having their minus sign interpreted as a whitespace control character by accident.
This is also the case in statements ({%
), though I don't know of a valid statement off the top of my head that could start with a negative number.
I should be able to fix this relatively easily.
from jinjava.
I've managed to fix the whitespace control problem locally, but it's revealed another issue with operator precedence. Specifically, the unary minus should bind tighter than operators like is
; that is, -1 is integer
should evaluate the same as (-1) is integer
. However, currently Jinjava evaluates this as -(1 is integer)
which is obviously incorrect.
This is a tougher issue to untangle, but I did a fair amount of digging yesterday and hope to make some more progress today. I opened #893 to capture this issue.
from jinjava.
I had to revert #896 while we look into some templates that no longer parse successfully with these changes.
from jinjava.
Related Issues (20)
- Template Render to keep unresolved variables as-is in the output HOT 4
- Update dependencies with vulnerabilities
- Dependency org.yaml:snakeyaml, leading to CVE problem
- for else control structure doesn't seem to be supported HOT 1
- Engine performance HOT 2
- render template that it is contains one '\r\n' string will return more than one
- Can Dict key be an integer? HOT 2
- CVEs in current version: 2.7.0
- time for 2.7.1 / 2.8.0 ?
- Unexpected behavior comparing empty strings to 0
- Is the expression interpolation recursive? HOT 1
- Problem with using the function in nested interpretation HOT 2
- SnakeYAML 1.27 vulnerability in Jinjava 2.7.1 HOT 1
- Add {% hubl %} tag
- Maps in string representation in Сontext
- Support for "with" statement
- Resolve function with map like contructs HOT 1
- Mixing include and extends does not work
- Fix CVEs in version 2.7.1
- Inconsistent implementation with jinja2 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jinjava.