Firstly, the 'render' object should be an automatic global. Templates
should have access to the template environment.
Then we add a $return directive, with the syntax:
$return <any string or __str__able object>
Doing `$return self` would emulate the usual behaviour (but of course
that would not be required). Meanwhile, you could also do $return
render.someOtherTemplate(self) or whatever you need to do. To
demonstrate, here's how the example from
<http://webpy.infogami.com/templetor> would work.
page.html:
$def with (post)
$var title: $post.title
<p>$markdown(post.body)</p>
<p class="byline">by $post.author</p>
$return render.base(self)
base.html:
$def with (body)
<html><head>
<title>$body.title</title>
</head><body>
<h1>$body.title</h1>
$body
</body></html>
That way, you can just call page(post), instead of base(page(post))
(which, as I explained elsewhere, is rather inelegant and violates MVC
separation). The template itself elects to pass its output through
base.html before returning; that's not a job for the controller.
As a side effect, making the render object an automatic global will
also allow simple inclusion, for those who prefer that style to the
inheritance model.
Thoughts?