-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configuring Jinja2 extensions #117
Comments
I'm not pretty sure that this approach is really good idea, independently of how jinja2 convention is :S In my opinion, the extesion should be isolated and self-sufficient. Use environment for set some params that some extensions may use, seems like a very bas approach. I'm missing something? |
http://jinja.pocoo.org/docs/dev/extensions/#jinja2.ext.Extension
So there really isn't any other way, and some extensions will need configuration. See also for example the fragment extension example in the Jinja2 docs. |
I understand... I will think something for solve it. |
I think that an other solution for this is some kind of hook, that will be called when all environment is up and running, that hook will receive the environment. This will decouple a little bit the environent from the configurations of third party extensions. That do you think? |
I like the idea. I don't necessarily buy the decoupling argument, but since Jinja doesn't have an API for this and you are essentially just making arbitrary modifications of the environment object, it seems just as well that the user should do this in code, not via some interface. |
closing this as it's 7 years old. |
Jinja2 has this idea that when extensions need configuration, it should be done by setting attributes on the environment. It seems to be that this is currently pretty hard - I am doing this now:
The text was updated successfully, but these errors were encountered: