-
-
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
Overriding Variables of Outer Scopes #44
Comments
I will keep it in mind for the new compiler backend, but in the current one that is not possible to achieve for performance reasons. |
I'd like to see this too. |
+1 |
I would like to see this too. I'm trying to perform simple running totals in some generated data..and that functionality is what I need. |
+1 |
1 similar comment
+1 |
+1 I also think that this behaviour should be unacceptable:
This will output 3 The variable resets after each outer loop run, even though it was declared OUTSIDE of all loops. I can't see how this would be expected behaviour. Is this a bug ? |
+1 I also think that this behaviour should be unacceptable:
This will output 3 The variable resets after each outer loop run, even though it was declared OUTSIDE of all loops. |
+1 |
This would very useful when templating JSON files. +1 |
+1 |
Me too, could really use an override and it'd be great if the template designer docs explicitly mentioned this behavior! I had to work with some data in an (admittedly horrible) format and was puzzled at why the followed pre-pass didn't work...
I agree with @ruiposse's comment that having a variable first set outside all loops reset itself inside them is very unexpected. |
+1 |
I'm going to close this. This cannot work in all cases in Jinja2 and I do not really wish on supporting it. |
In Jinja 1.2 there was a feature that allows us to override outer scope variables from within a inner scope, by adding an exclamation mark after the set statement.
This feature is somehow missing in Jinja2. However, such feature is often required. Here is a real-world example in stackoverflow:
http://stackoverflow.com/questions/4870346/can-a-jinja-variables-scope-extend-beyond-in-an-inner-block
It would be glad to see such feature back again in Jinja2 ; )
The text was updated successfully, but these errors were encountered: