On Fri, Aug 03, Ivan Sagalaev wrote:

> 
> Michael Radziej wrote:
> > {% autoescape %} always needs an {% endautoescape %}, generating a node
> > during template parsing. Everything between {% autoescape %} and {%
> > endautoescape %} is put in its subnode list.
> > 
> > If a VariableNode is below an {% autoescape on %} in the template node tree,
> > autoescape is in effect, if it is below an {% autoescape off %}, it won't.
> > (Deepest autoescape node wins, of course.) 
> 
> So this "deepest wins" effectively means that one can't set autoescaping 
> to "off" from a base template as James was suggesting, right? (I'm not 
> against it, just trying to clarify.)

To make this clear, I'll provide an example:


base.html:

{% autoescape off %}
  <html><body>

  {% block bla %}
    <p>{{xyz}}</p>
  {% endblock bla %}
  </body></html>
{% endautoescape %}


sub.html:

{% extends "base.html" %}

{% block bla %}
  {% autoescape on %}
    <p>And now to something completely different: {{abc}}</p>
  {% endautoescape %}
{% endblock bla %}



If you use sub.html, abc will be escaped due to the {% autoescape on %} in
the line above. That's the 'deeper' rule: There's not a global switch to
switch autoescape on or off.

Michael


-- 
noris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg -
Tel +49-911-9352-0 - Fax +49-911-9352-100
http://www.noris.de - The IT-Outsourcing Company
 
Vorstand: Ingo Kraupa (Vorsitzender), Joachim Astel, Hansjochen Klenk - 
Vorsitzender des Aufsichtsrats: Stefan Schnabel - AG Nürnberg HRB 17689

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

Reply via email to