Tuesday, October 25, 2011

block behavior does not work as documented with respect to autoescape

In the current Django 1.3 documentation on templates
(https://docs.djangoproject.com/en/1.3/topics/templates/#for-template-
blocks), the documentation mentions the following:

"The auto-escaping tag passes its effect onto templates that extend
the current one as well as templates included via the include tag,
just like all block tags"

And the following example is provided:
# base.html

{% autoescape off %}
<h1>{% block title %}{% endblock %}</h1>
{% block content %}
{% endblock %}
{% endautoescape %}


However, this doesn't actually seem to work, as illustrated in the
following example,
a = '''
{% autoescape off %}
<h1>{% block title %}{{ hello }}{% endblock %}</h1>
{% block content %}
{% endblock %}
{% endautoescape %}
'''
from django.template import Context, Template, TemplateSyntaxError
django_template = Template(a)
context = Context({"hello": 'world'})

print django_template.render(context)

when encountering the line "django_template = Template(a)", django
throws an exception:
django.template.base.TemplateSyntaxError: Invalid block tag: 'block',
expected 'endautoescape'

Am I reading the documentation wrong, or is there a Django error here?

Thanks,
--psbanka

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate