On 20 Sep 2007, at 11:18, bubblboy wrote:
> So, I am not exactly familiar with Adam Atlas's implementation, but  
> does
> it allow templates to import ("include") other templates?

It's not "inclusion" in the style of PHP (where it's treated as  
though the included template was placed inline in the containing  
template), but it does make the `render` object an automatic global  
for templates, so you can use that to easily call other templates.

It currently also supports a sort of inheritance by way of $return. I  
think Aaron doesn't like that; I'm still open to other ideas. I was  
thinking of adding support for decorators ([EMAIL PROTECTED] at the top of the  
template, before any $def line), and including an `inherit` decorator  
which would also be an automatic global, and would look something  
like this:
def inherit(parent, *args, **kwargs):
     def dec(func):
         def _f(*_args, **kwargs):
             return parent(func(*_args, **kwargs), *args, **kwargs)
         return _f
     return dec

For example, if you have these templates:

#base.html
$def with (body, title)
<title>$title</title>
$:body

#index.html
Hello

Then adding [EMAIL PROTECTED](render.base, 'Hi') to the top of index.html  
would make it equivalent to calling render.base(render.body(), 'Hi').  
(Also equivalent would be adding `$return render.base(self, 'Hi')` to  
the bottom.) I suppose we should narrow this down (or at least  
standardize on one preferred style) on the principle of "There should  
be one -- and preferably only one -- obvious way to do it."

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web.py" 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/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to