1. specifying globals in web.template.Template.globals is not nice.
What if i want to render templates from two different directories,
each with different set of globals?
Isn't it better to specify globals to the render function?
example:
render = web.template.render('templates/', globals=dict
(datestr=web.datestr))
2. using python style indentation in templating is sometimes painful.
Suppose i want to generate the following text.
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
if i use the following template
$ a = [1, 2, 3, 4]
<ul>
$for i in a:
<li>$i</li>
</ul>
it produces
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
But i missed the spaces before <li>. It doesnt matter much in most of
the web.py applications since we are dealing with html, but it is not
nice!
How about having $end? so the above template will become:
$ a = [1, 2, 3, 4]
<ul>
$for i in a:
<li>$i</li>
$end
</ul>
This preserves the whitespace and produces exactly what is desired.
anand
Oops, yeah, I think you're right. Can you send me a patch that adds
this feature?
> 2. using python style indentation in templating is sometimes painful.
> Suppose i want to generate the following text.
Yeah, this bugs me too, but the $end statements bug me even more. I
sometimes wonder if maybe it should add the indentation to the output
as well, with maybe an option to suppress it.
E.g. in...
<ul>
$for i in a:
<li>$i</li>
</ul>
...the parser would notice that it has some leading spaces and would
retain those during all iterations?
It's supposed to do that.
So:
<ul>
$for i in a: <li>$i</li>
</ul>
would be a sensible way of writing it.
> It's supposed to do that.
Oh, and it does! For some odd reason I thought it didn't. Thanks for
the correction.
I think there's still a minor issue with subtemplates...
<ul>
$for i in a: $:render.item(i)
</ul>
...if item.html happens to contain multiple lines.