jinja2cpp / Jinja2Cpp

Jinja2 C++ (and for C++) almost full-conformance template engine implementation
https://jinja2cpp.github.io
Mozilla Public License 2.0
500 stars 85 forks source link

Support for index-based arrays slicing #120

Open flexferrum opened 5 years ago

flexferrum commented 5 years ago

Jinja2 index operator [] follows the python arrays slicing semantic: https://stackoverflow.com/questions/509211/understanding-slice-notation

It needs to be supported.

layderv commented 5 years ago

For the parser, it looks like ParseSubscript() is to be updated to support [ : : ].

For the evaluator, I think SubscriptExpression::Evaluate is the one to edit, but I don't quite understand how / the types that are involved in that method. Can I get any suggestion please?

flexferrum commented 5 years ago

For the evaluator

I've considered to add new AST node for this purpose, something like SliceExpression, because indexing and slicing has got too different behavior.