Replies: 3 comments
-
why do you want to add even more logic to templates? any particular use case? |
Beta Was this translation helpful? Give feedback.
-
One particular one would be where an engine uses Jinja2, but I don´t have access to the executing environment. e.g. the https://github.com/cookiecutter/cookiecutter package. Adding filters is possible, but not guaranteed to be available for someone who has only cookiecutter installed. So this way, basically many things that would currently require a custom filter in python could be written this way, I think. Anything that in Jinja itself needs chaining of several filters and other gymnastics could be written in a more 'python' way by providing starlark functions that do the work. Currently running arbitrary code in Jinja is of course possible using filters, but it does require access to the execution environment. As Starlark is safe to run untrusted code, i thought this could be a powerful way to extend it. And as it is a subset of python, jinja2 users should easily be able to use it. |
Beta Was this translation helpful? Give feedback.
-
Other than that, I also thought it could help bridge the gap between the functionality of the python jinja2 and the rust version (minijinja). Obviously custom python filters can´t work in minijinja, but starlark could (there is a rust-version of starlark). |
Beta Was this translation helpful? Give feedback.
-
Hi,
I am still a relative newby to Jinja2. I like it, but occasionally it just feels like some programming ability is missing inside it to make things simpler. Naively, I was wondering if anyone has thought about integrating e.g. Starlark into jinja2. As Starlark is intended for configuration and is safe for untrusted code, this could be a very powerful way to extend the current ability.
Thoughts?
Beta Was this translation helpful? Give feedback.
All reactions