lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi,

thanks, yes that makes sense. I was way too deep in 'template world'.
The entire idea of parclate is that the tag commands contain valid lua
code so that is a perfectly good check.

The only issue is, and that has to do with the original posting about
environments, next() is not known in the environment of the template but
that can be worked around easy enough:
t=Parclate(templ_string)()

t.thetable = {what='ever', and so on}
t.next     = next
print(t) -- > rendered output

The reason for that is that I don't want people to do too much logic in
the templates. That's bad style and leads to unreadable code. So it
shall be a little more complicated and obvious when people do logic
there.

	- T

On Tue, 19 Jan 2010, Peter Odding wrote:

> Tobias Kieslich wrote:
> >That shall be easy enough to write. Now for hash tables the "if empty"
> >expression is not as easy but that always depends on the situation.
> 
> Please ignore me if this makes no sense (I've never used/needed a
> templating engine in Lua), but wouldn't the following "if" condition
> suffice for hash tables that are empty?
> 
> <elem l:for="i,v in ipairs(table)" l:strip="">
> 	<b>${i}.</b> <span>${v}</span>
> </elem>
> <elem l:if="next(table)==nil">
> 	It was just empty, too bad :(
> </elem>
> 
>  - Peter Odding