Re: YATS (Yet another templating system)

[email protected] (Andrei Zmievski)
Newsgroups php.template
Message-ID <[email protected]>
On Tue, 15 Feb 2000, Dan Libby wrote:
> The design is also derived from fasttemplate, but deviates more
> significantly, I think.  In particular, parsing occurs only once, when
> the template is defined/loaded.  Thus, there is no need for
> parse_dynamic().  The template syntax is also different.  It allows
> nested dynamic sections.  It does not allow conditionals, but has
> support for an "alt" parameter if the requested variable is not found.
> Other parameters may be defined as needed due to the {{var key1="val"
> key2="val"}} syntax.  There is support for implicit looping, and
> (optional) automatic hiding of sections with undefined variables.

So basically just by assigning multiple values to the section variables
you make them loop, correct?

> Anyway, I was wondering what to do with this code.  I could place it on
> sourceforge, or try to get it into the PHP distro, or sit on it.  I was
> happy to discover this list and andrei's proposal sounds similar in many
> regards to what I had come up with.  I have some documentation, which
> I am including with this mail (readme.HTML). I would like to hear your
> feedback on my design, and would also appreciate any thoughts on how
> best to distribute the code.

If you don't mind I'd like to take a look at the code and see what state
it's in.

> 
>   Syntax:
>   
>    {{variable_name}} or
>    {{variable_name key1="val1" key2="val2"}}

What do key1 and key do?

>    {{section:section_name}} ...  some stuff ... {{/section:section_name}}
>    or
>    {{section:section_name key1="val1" key2="val2"}} ...  some stuff ...
>    {{/section:section_name}} or

>   Automatic Hiding
>   
>    If any variable is not found within a section, the entire section will
>    be hidden.  This can be useful when there is surrounding text (such as
>    a table row) that should only be displayed if the variable is found.
>    Child sections are also hidden.

This should be configurable.

>   Implicit Looping
>   
>    [note: subject to change.]  The simplest case is a section with one
>    variable that contains a list of two values.  This section will be
>    repeated twice, with value1 inserted the first time and value2
>    inserted the second time.  The situation becomes more complicated when
>    the section contains multiple variables because of the possibility of
>    a mis-matched number of values per variable.  For example, var1 may
>    contain 2 values and var2 contains 3 values.  In this case, the
>    section loops twice, and the extra value in var3 is simply discarded.
>    It is the responsibility of the PHP code to correctly align these
>    value lists.

It's a pretty good idea. It does require more memory since you would be
assigning all the variables at once and on pages where sections are
repeated for potentially large number of times it might be a bit
wasteful. Basically, no way to get a result from database and then
assign section vars. You'd have to accumulate the results in arrays and
then assign them.

I think what templates should also have is:
	- comments
	- possible support for loading config files (I'm undecided on this
	  now)
	- possible optional evaluation of the template if it has embedded
	  PHP code (that's how you would do includes)

-Andrei

Complexity in the mind is not caused by learning;
learning is caused by complexity in the mind.
                                 -- Steven Pinker
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.