[Django]-Jquery template tags conflict with Django template!

13👍

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.

2👍

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.

0👍

I’m using Django 1.3 and adding

{% raw %} this should be ignored by django's template framework {% endraw %}

to my html file.

The server returns with a:

Invalid block tag: ‘raw’

Also in the docs I can’t seem to locate information about this tag you’re talking about.

https://docs.djangoproject.com/en/1.3/ref/templates/builtins/

0👍

There’s great information here on using Django templates, using icanhaz, but I think this is similar enough to JQuery templates.

http://tothinkornottothink.com/post/4282971041/using-jquery-templating-icanhaz-js-with-django

0👍

I’ve found defaults to be useful if no ‘verbatim’ tag is supported.
Looks like this:

{{ some_undefined_variable|default: '....here goes the subject template....'}}

PS. Note for users of ChicagoBoss, which has no support for ‘verbatim’ tag in ErlyDTL.

Leave a comment