logo       

Re: the "Cheetah files" (part 1): msg#00020

python.cheetah

Subject: Re: the "Cheetah files" (part 1)

On Mon, Oct 06, 2003 at 11:53:09AM +0200, deelan wrote:
> >And actually implementing an "if empty" portion in #for
> >would be a lot of work. Since the "list" can be any iterable, you'd
> >have to prefetch the first element specially and do something different
> >if it didn't exist. And even if we did this, there's no place for
> ><UL> and </UL> -- not unless we added two more #for portions for
> >"before" and "after". It starts getting really complicated, and a
> >standard #for combined with #if/else or #unless starts looking the
> >epitome of readability by comparision.
>
> this is something it could be implemented in version 2.0 of the
> template system. maving from python-like statemenet to a more rule-based
> machinery, like zope's TAL or mozilla's XUL:
>
> http://www.xulplanet.com/tutorials/xultu/templates.html
>
> but this really would distort cheetah philosophy a lot. having rules
> like #ifempty would look a bit strange. :)

#for ... #ifempty ... #end for
would be marginally acceptable since the clause is obviously an
extension to the Python form, and maintainers who don't know what it
means would run to the docs rather than mistakening it for something
else.

We always judge new directives according to their benefits/work ratio,
and this one has a relatively low value, especially since existing
syntaxes are almost as clear.

I'm not sure what you mean by "maving from python-like statemenet to a
more rule-based machinery, like zope's TAL or mozilla's XUL:". As you
know, XML-syntax directives were explicitly rejected in Cheetah. And
we prefer to use Python-compatible syntax as widely as possible, so
maintainers can think in their favorite language rather than learning
a new one (and its limitations). It also allows ppl to port methods
between Python and Cheetah relatively easily.

However, if "rules-based" means a different concept, or a different kind
of directive, we are open to it. But you'll have to explain it in
simple terms because I don't have a Computer Science degree, and I get
lost trying to understand XML formats.

We've discussed giving users the ability to write their own extension
directives, but the Cheetah core (unlike Smarty) was not designed with
that in mind. Only Tavis understands how to add a directive. When I
tried to implement #indent, I did it as a preprocessor that converted
it to $placeholder calls on a hidden object.

PS. That $html_list method I posted could use #include to parse the
content of each list element. That would allow you to use a method
rather than a #for loop, without losing the ability to put
$placeholders in your <LI> values. Just remember the method won't
see local variables in the parent, only searchList and '#set global'
variables.

--
-Mike Orr (aka. Sluggo), mso@xxxxxx (iron@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)
http://iron.cx/ English * Esperanto * Russkiy * Deutsch * Espan~ol


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise