Today I'm trying to play with jquery-tmpl {{if}} & {{else}} statements.
<script id="mission-dialog" type="text/x-jquery-tmpl">
<h3>${name}</h3>
<p>${description}</p>
<ul>
{{each(i,cond) conditions.data}}
<li>
<img src="${cond.image}"/>
<h4>${cond.name}</h4>
<p class="status">${cond.status.value}/${cond.status.max}</p>
</li>
{{/each}}
</ul>
</script>
But as you know {{ }} is reserved also for django template. So django will emit TemplateSyntaxError that it can't parse it.
How can I solve this problem?
updated:
I found a working <% raw %> custom tag (GPL) implementation from here.
http://www.holovaty.com/writing/django-two-phased-rendering/
Use the templatetag
template tag to render the brackets:
{% templatetag openvariable %}each(i,cond) conditions.data{% templatetag closevariable %}
It's a bit fiddly, which is why a raw
template tag has been proposed for Django 1.3.
There are a few solutions mentioned here:
https://github.com/nje/jquery-tmpl/issues#issue/17 - Edit: Old repo
https://github.com/jquery/jquery-tmpl/issues/#issue/74
My favorite is the {% verbatim %}
template tag that allows you to build jQuery templates from within Django ones.
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