--
You received this message because you are subscribed to the Google Groups "Django developers" group.
To post to this group, send email to django-d...@googlegroups.com.
To unsubscribe from this group, send email to django-develop...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.
To post to this group, send email to django-d...@googlegroups.com.
To unsubscribe from this group, send email to django-develop...@googlegroups.com.
(technically, there is an open jquery-templating ticket about making
the template-tag format customizable:
https://github.com/jquery/jquery-tmpl/issues/74)
i had the same problem in the past (btw. mustache.js also uses the
two-curly-braces notation :-),
and unfortunately the verbatim tag did not solve the problem, because
sometimes you need
to use the django-templating INSIDE the jquery template
.
for example:
"""
.
.
<script type="text/x-jquery-tmpl">
Are you sure to delete {{ name_of_thing }}?
<button>{% trans "YES"%}</button>
<button>{% trans "NO"%}</button>
</script>
"""
here i want the {{ name_of_thing }} to be handled by
jquery-templating, but the translation
should happen using the django-tags.
so either i have to use the {% verbatim %} tag only around the places
where i have javascript-variables
(and not around the whole jquery-template), or i have to do the
translation in python,
and send them in as variables in javascript. both seem to be impractical.
the approach i chose was to use a different variable-syntax
(instead of "{{ thing }}", i use "[[ thing ]]"), and before using the template,
i simply replace those with the correct values. it's not nice, but
still the most practical solution i could find.
gabor
I wonder if verbatim as a filter makes more sense, for example::
<script type="text/x-jquery-tmpl">
Are you sure to delete {{ "{{ name_of_thing }}"|verbatim }}?
<button>{% trans "YES"%}</button>
<button>{% trans "NO"%}</button>
</script>
The filter would then just return {{ name_of_thing }} back to the
template. If you wanted to use a template variable as the name of the
jQuery variable this approach would still fail.
Now that I think about it maybe the replace tokens approach is the
most flexible.
{% verbatim "[[" "]]" %}
<script type="text/x-jquery-tmpl">
Are you sure to delete [[ name_of_thing ]]?
<button>{% trans "YES"%}</button>
<button>{% trans "NO"%}</button>
</script>
{% endverbatim %}
You you could then choose the tokens that get replaced.
- Sean