Created
February 22, 2013 11:45
-
-
Save bmispelon/5012913 to your computer and use it in GitHub Desktop.
Bug in django's forloop template compiling
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.template import Template, Context | |
| CONTEXT = Context({ | |
| 's': '', | |
| }) | |
| for tpl in [ | |
| '{% for x in s|add:"a b c" %}-{{ x }}{% endfor %}', # Doesn't work | |
| '{% with v=s|add:"a b c" %}{% for x in v %}-{{ x }}{% endfor %}{% endwith %}', | |
| '{% with v="a b c" %}{% for x in s|add:v %}-{{ x }}{% endfor %}{% endwith %}' | |
| ]: | |
| s = Template(tpl).render(Context({'s': ''})) | |
| assert s == u'-a- -b- -c' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment