I would suggest also adding a way to exclude all context except items
specified with the with syntax.
(nocontext keyword or something like that).

Because sometimes I have certainly named items in my context which can
also be used in the included template but I don't want there. Sure you
can overwrite them one by one, but the faster and cleaner way would be
to exclude the whole context.


On Oct 29, 3:22 am, Russell Keith-Magee <russ...@keith-magee.com>
wrote:
> On Wed, Oct 27, 2010 at 3:46 PM, SmileyChris <smileych...@gmail.com> wrote:
> > On Oct 27, 5:35 am, Łukasz Rekucki <lreku...@gmail.com> wrote:
> >> I would like to bring this up again, because this is something that
> >> would really improve readability of my templates. I'm mainly
> >> interested in ticket #7817 (the include tag changes), but extending
> >> "with" tag (ticket 9456) would keep things consistent.
>
> > Here's a link to the ticket for the lazier ones among us:
> >http://code.djangoproject.com/ticket/7817
>
> > The main decision which needs to be made is one of syntax.
>
> > The current proposal uses:
> > {% include "name_snippet.html" with name="Joe" greeting="Hello" %}
> > but this introduces an inconsistency with the {% with %} tag.
>
> > Consistency would be nice, but I think this starts to look a bit
> > confusing, static tokens outnumbering actual functional ones:
> > {% include "name_snippet.html" with name as "Joe" and greeting as
> > "Hello" %}
>
> > My proposal is that the current {% with name as "Joe" %} format
> > becomes the legacy format, and that the new format becomes (also
> > allowing for multiple arguments):
> > {% with name="Joe" greeting="Hello" %}
>
> > Other tags which currently use the "as" token are: cycle, regroup and
> > url. These all introduce a new variable into the current context,
> > which does differ slightly from how {% with %} alters a variable in a
> > contained scope. So my secondary (perhaps somewhat feeble) argument is
> > that this actually helps to keep the "as" token's behaviour more
> > consistent. :)
>
> > Thoughts?
>
> Repeating what I said to Chris in IRC for the benefit of posterity:
>
> I don't have any strong preference either way, but whatever style we
> pick, we need to be consistent.
>
> I can certainly appreciate the clarity and terseness of the "foo=bar
> pork=ham" syntax. My only concern would be whether it is too
> "programmery" for the intended audience of the template language. We
> have existing uses of the 'x=y' syntax -- such as in the {% url %}
> tag, so I don't think this should be a major concern.
>
> As David points out, the fact that {% blocktrans %} already does 'with
> X as Y and A as B' would seem to set a precedent for the verbose
> syntax. This verbose syntax is also syntactically consistent with what
> the {% with %} tag already does, so there's no need to introduce a
> 'legacy' format.
>
> I could swing either way on this. If we were starting with a clean
> slate, I'd prefer the terse syntax, and I think Chris provides a
> reasonable argument for how the usage of 'as' can be explained
> conceptually. However, the legacy issue and the precendent set by {%
> blocktrans %} provides a compelling argument to use the more verbose
> syntax.
>
> If we can introduce the terse syntax while maintaining the old syntax
> (including the analogous change in  blocktrans), I think it would be a
> worthwhile change. However, I certainly won't complain if public
> opinion sways the other way.
>
> Yours,
> Russ Magee %-)

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

Reply via email to