admin管理员组文章数量:1317898
I am using jinja2 templating language in my GAE-python project. I have tried to use the jquery-upload for uploading files.
The following code is throwing an error:
<!-- The template to display files available for upload -->¬
152 <script id="template-upload" type="text/x-tmpl">¬
-- 153 {% for (var i=0, file; file=o.files[i]; i++) { %}¬
| 154 <tr class="template-upload fade">¬
| 155 <td class="preview"><span class="fade"></span></td>¬
|- 156 <td class="name"><span>{%=file.name%}</span></td>¬
The above code is directly taken from the jquery upload library.
The error:
line 153, in template
{% for (var i=0, file; file=o.files[i]; i++) { %}
TemplateSyntaxError: expected token ')', got 'i'
I think it is being caused due to the {% %}
which is used by jinja2 as well as the text/x-tmpl js syntax. Is this correct? If so,
How can I work around it? Please help.
I am using jinja2 templating language in my GAE-python project. I have tried to use the jquery-upload for uploading files.
The following code is throwing an error:
<!-- The template to display files available for upload -->¬
152 <script id="template-upload" type="text/x-tmpl">¬
-- 153 {% for (var i=0, file; file=o.files[i]; i++) { %}¬
| 154 <tr class="template-upload fade">¬
| 155 <td class="preview"><span class="fade"></span></td>¬
|- 156 <td class="name"><span>{%=file.name%}</span></td>¬
The above code is directly taken from the jquery upload library.
The error:
line 153, in template
{% for (var i=0, file; file=o.files[i]; i++) { %}
TemplateSyntaxError: expected token ')', got 'i'
I think it is being caused due to the {% %}
which is used by jinja2 as well as the text/x-tmpl js syntax. Is this correct? If so,
How can I work around it? Please help.
2 Answers
Reset to default 9Try this:
{{ '{% for (var i=0, file; file=o.files[i]; i++) { %}' }}
Or you can use {% raw %} {% endraw %} blocks.
http://jinja.pocoo/docs/templates/#escaping
I've had problems while using Flask and Angular. That helped! Figured it might be helpful for other people.
http://flask-triangle.readthedocs/en/develop/tutorial/part1.html
本文标签: Jinja and javascript syntax conflictStack Overflow
版权声明:本文标题:Jinja and javascript syntax conflict? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742035482a2417267.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论