On Jan 21, 10:11 am, Malcolm Tredinnick <malc...@pointy-stick.com> wrote: > > Coming back from the generalization to my usecase, i cannot see how > > > {% with a as b %} > > {% with x as y %} > > {% include "foo.html" %} > > {% endwith %} > > {% endwith %} > > > is syntactically or semantically superior to > > > {% include "foo.html" with a as b, x as y %} > > Because, no code will ever be that short. People don't use one-letter > variable names for a start (those that do should stop).
OK I admit I was cheating a bit ;) > We're not discouraging modular coding. Far from it. We're simply saying > that there aren't template-level namespaces (which is all that variable > aliasing is in programming languages). If you're going to substitute > things into template foo.html, use the same names all the time. Use > common, descriptive names in foo.html and the views that include that > data won't be unclear. There are enough descriptive words in the English > language (or language of choice) that avoiding name collision just isn't > that hard. Well in the case of components you will want to use the same component on the same page in different contexts. Since the number of such components is always limited and they should have well-defined semantics anyway I will go with a non-generic template inclusion tag for each of these components now, I guess. for future readers: http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#inclusion-tags Maybe the documentation of the include tag should contain a not like "If you want to use more sophisticated include patterns like passing parameters to included templates, take a look at creating inclusion tags (link)" - I think this is really something that people coming from other frameworks have to be pointed to. Thanks for the insightful discussion, as always! Flo --~--~---------~--~----~------------~-------~--~----~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---