On 7/30/06, SmileyChris <[EMAIL PROTECTED]> wrote:
> 1. Technically, the view decides how a template is going to be
> displayed, not the template itself. Could the view, therefore, be the
> best place for escaping to happen?

The view decides which template to use, and what variables will be
made available to the template, but that's not really the same thing;
the question here is "which layer of Django decides what the actual
output bits will be that go over the wire?" And the answer is mostly
the template, because that's where the output is structured and
coddled and worked into whatever form is desired.

> 2. The only things that really ever need escaping are variables passed
> to the template (most likely from a view). Why should the template
> author have to define whether these  variables passed from another
> layer should be escaped?

What happens when someone uses a simple template tag to add variables
to the context that weren't supplied by the view? If nothing else,
that seems to be the death knell for escaping controls in the view,
because then we'd have to go down a DRY-violating road of "remember to
turn on escaping in your view *and* remember to turn on escaping in
your template tags".

> 3. The idea of a "template" is DRY. If I wanted to use a template block
> in several views for an email, an html page and a javascript block, I
> should be able to use just the one template. Wouldn't then this make
> more sense for the view to determine any necessary escaping for
> variables?

No. Again, the template is what decides how the output will actually
look, and it's possible to do tons and tons of output formats in
Django templates where escaping just doesn't make sense; the
"escaping" we're talking about here basically only applies to
templates which output HTML or other SGML- or XML-derived markup
languages; CSV doesn't need this kind of escaping, PostScript doesn't
need it, PDF doesn't need it, LaTeX doesn't need it... and those are
all things that you can use the Django template system to output.

-- 
"May the forces of evil become confused on the way to your house."
  -- George Carlin

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

Reply via email to