-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Support passing arguments to {% include %} tag. #241
Comments
It strikes me that this could possible be implemented by an Extension that generates with and incude nodes. |
There are a couple of ways to do this. The Django style:
The Twig style (equivalent to the above):
The Twig style does provide some additional flexibility:
Note that this functionality is not achievable using the
I've implemented the "Twig style" of this in a separate Jinja extension library, but in order to avoid branching jinja itself, I've had to subclass Template and Environment, I've had to copy and paste a lot of boilerplate, and I've even had to monkey patch a little. Adding the functionality directly to jinja would be much cleaner and involve much less code. I'd love to put a patch together, if there was some willingness to incorporate the functionality. Is there any possibility that this feature would be accepted into Jinja? |
in jinja 2.9+ you can just wrap the |
Would a patch to this effect be merged?
There are some scenarios where you want a have short syntax for useful helper, and using the {% with %} tag is not exactly succinct.
Even the Django guys, reputed to be ultra-conservative about their template language, supports this now.
The text was updated successfully, but these errors were encountered: