Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery causing TemplateSyntaxError in Django
    text
    copied!<p>I'm getting the following error:</p> <pre><code>Exception Type: TemplateSyntaxError Exception Value: 'for' statements should use the format 'for x in y': for (var i=0, file; file=o.files[i]; i++) { </code></pre> <p>But I can't figure out how to escape it in Django, I've added <code>{% autoescape off %}</code> tags but still, no luck.</p> <p>Here is the code causing the error:</p> <pre><code>{% for (var i=0, file; file=o.files[i]; i++) { %} &lt;tr class="template-upload fade"&gt; &lt;td class="preview"&gt;&lt;span class="fade"&gt;&lt;/span&gt;&lt;/td&gt; &lt;td class="name"&gt;&lt;span&gt;{%=file.name%}&lt;/span&gt;&lt;/td&gt; &lt;td class="size"&gt;&lt;span&gt;{%=o.formatFileSize(file.size)%}&lt;/span&gt;&lt;/td&gt; {% if (file.error) { %} &lt;td class="error" colspan="2"&gt;&lt;span class="label label-important"&gt;{%=locale.fileupload.error%}&lt;/span&gt; {%=locale.fileupload.errors[file.error] || file.error%}&lt;/td&gt; {% } else if (o.files.valid &amp;&amp; !i) { %} &lt;td&gt; &lt;div class="progress progress-success progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"&gt;&lt;div class="bar" style="width:0%;"&gt;&lt;/div&gt;&lt;/div&gt; &lt;/td&gt; &lt;td class="start"&gt;{% if (!o.options.autoUpload) { %} &lt;button class="btn btn-primary"&gt; &lt;i class="icon-upload icon-white"&gt;&lt;/i&gt; &lt;span&gt;{%=locale.fileupload.start%}&lt;/span&gt; &lt;/button&gt; {% } %}&lt;/td&gt; {% } else { %} &lt;td colspan="2"&gt;&lt;/td&gt; {% } %} &lt;td class="cancel"&gt;{% if (!i) { %} &lt;button class="btn btn-warning"&gt; &lt;i class="icon-ban-circle icon-white"&gt;&lt;/i&gt; &lt;span&gt;{%=locale.fileupload.cancel%}&lt;/span&gt; &lt;/button&gt; {% } %}&lt;/td&gt; &lt;/tr&gt; {% } %} &lt;/script&gt; &lt;!-- The template to display files available for download --&gt; &lt;script id="template-download" type="text/x-tmpl"&gt; {% for (var i=0, file; file=o.files[i]; i++) { %} &lt;tr class="template-download fade"&gt; {% if (file.error) { %} &lt;td&gt;&lt;/td&gt; &lt;td class="name"&gt;&lt;span&gt;{%=file.name%}&lt;/span&gt;&lt;/td&gt; &lt;td class="size"&gt;&lt;span&gt;{%=o.formatFileSize(file.size)%}&lt;/span&gt;&lt;/td&gt; &lt;td class="error" colspan="2"&gt;&lt;span class="label label-important"&gt;{%=locale.fileupload.error%}&lt;/span&gt; {%=locale.fileupload.errors[file.error] || file.error%}&lt;/td&gt; {% } else { %} &lt;td class="preview"&gt;{% if (file.thumbnail_url) { %} &lt;a href="{%=file.url%}" title="{%=file.name%}" rel="gallery" download="{%=file.name%}"&gt;&lt;img src="{%=file.thumbnail_url%}"&gt;&lt;/a&gt; {% } %}&lt;/td&gt; &lt;td class="name"&gt; &lt;a href="{%=file.url%}" title="{%=file.name%}" rel="{%=file.thumbnail_url&amp;&amp;'gallery'%}" download="{%=file.name%}"&gt;{%=file.name%}&lt;/a&gt; &lt;/td&gt; &lt;td class="size"&gt;&lt;span&gt;{%=o.formatFileSize(file.size)%}&lt;/span&gt;&lt;/td&gt; &lt;td colspan="2"&gt;&lt;/td&gt; {% } %} &lt;td class="delete"&gt; &lt;button class="btn btn-danger" data-type="{%=file.delete_type%}" data-url="{%=file.delete_url%}"&gt; &lt;i class="icon-trash icon-white"&gt;&lt;/i&gt; &lt;span&gt;{%=locale.fileupload.destroy%}&lt;/span&gt; &lt;/button&gt; &lt;input type="checkbox" name="delete" value="1"&gt; &lt;/td&gt; &lt;/tr&gt; {% } %} </code></pre> <p>I'm using the jQuery File Upload (jquery ui version) plugin. Can anyone explain to me how I can fix this?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload