Extensions?
Jinja2 has the concept of extensions that you can define yourself (templatetags in django). It would be interesting to get that feature into tera as well.
Semi-related; I was exploring the viability of building a python library on top of tera using pyo3. So in a way that would go full circle ;). One of the things missing is extensions for that.
Tera already kind of supports that since you can add custom filters/tests/global functions. You cannot extend the parser though.
I was exploring the viability of building a python library on top of tera using pyo3.
I thought about it but you would lose some things that are too "nice" in python, like passing SQLAlchemy objects to the template (those cannot be converted to JSON for example)
I thought about it but you would lose some things that are too "nice" in python, like passing SQLAlchemy objects to the template (those cannot be converted to JSON for example)
I can see that this could be an obstacle. There are object serializers though such as what the drf library provides, which could provide a bridge for this.
You cannot extend the parser though.
I understand that you cannot extend the parser to parse new elements such as {% mynewthing param param %}{% endmynewthing %}. But would it be possible to create a catch all element in the parser where mynewthing is passed onwards to lookup how that should be executed / handled?
Maybe in a v2 but not in the current parser. Filter sections kinda cover that kind of usecases imo.
I'll keep my eyes out for it :)