New Jinja Parser
Uha. One day of programming and Jinja got a new parser :D 129 out of 131 tests pass, and nearly all of the old semantics still work. I changed some things so far that probably make more sense. Syntax changes from 1.1 to 1.2:
- call and endcall are keywords now. I wanted to do that in 1.3, not 1.2 but because it’s easy to change it’s a good thing to do the change now.
- tuples are tuples now, not lists. That will make strings formatting easier too — it really was a bad idea to uniform lists and tuples. This change shouldn’t cause many problems because the namespace is more or less read only. So there are no concatenation issues that will appear because a list and tuple are mixed together.
- __getslice__ is currently not supported. Parsing the python slice rules is not that simple and for the moment slice objects are easier. So foo[1:2] results in get_attribute(foo, slice(1, 2, None)). I will add some more unittests to check if this breaks stuff.
- foo|escape + bar|escape is possible now.
The code is not in trunk by now because there are still some things to fix (string escaping, streaming system) and i don’t know if the change has any side effects on bigger code. If someone wants to try out the new parser tough you can check it out from here: new-parser.
Backward incompatible changes: the lexer tokenstream, the lexer tokenize method (not the tokeniter one which is public) and the parse functions because the new parser looks different and has different nodes from different modules (no compiler.ast any more). I hope that there are few hardcore users that analyse the Jinja ast but if there are some, you probably have to change some code.