[Grok-dev] Re: first thoughts on "regebro-guido-templates"

Martijn Faassen faassen at startifact.com
Tue Oct 30 06:44:02 EDT 2007


> [snip]
> > I would like the template namespace() to be
> > responsible for both creating the default namespace, and updating it
> > with view.namespace().
> >
> > It's just a matter of moving the namespace.update(view.namespace())
> > from one method in the template to another, and hence no big
> > improvement in many cases, but I find it clearer, since the render
> > method gets much cleaner:
> >
> >     def render(self, view):
> >         return self._template.render(self.namespace())
> >
> > Basically, it goes from three lines to one, while the namespace method
> > goes from 6 to 7. It's silly to count lines, but... yeah, it just
> > feels...cleaner. :-)
> Okay, at first sight I can't see any drawbacks to this, so fine with me. :)

I just thought of a potential drawback. In the current design,
overriding namespace() on the template level has no particular
requirements. You just need to return a dictionary. Your change if I
understand it correctly, would add calling the view's namespace() for
all template developers. So you might save a few lines now, but you're
adding lines, and required knowledge and calls, for all template
language developers.

If my analysis is correct, I'm -1 to this change.



More information about the Grok-dev mailing list