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.
Try this:
{{ '{% for (var i=0, file; file=o.files[i]; i++) { %}' }}
Or you can use {% raw %} {% endraw %} blocks.
http://jinja.pocoo.org/docs/templates/#escaping
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With