Re: [PHP Template] Re: [PHP3] template engine example document
| From: | Monte Ohrt | Date: | Sat, 25 Mar 2000 17:20:19 +0000 |
| Subject: | Re: [PHP Template] Re: [PHP3] template engine example document | ||
| References: | 1 | Groups: | php.template |
| Request: | Send a blank email to php-template+get-469@lists.php.net to get a copy of this message | ||
Andrei Zmievski wrote:
>
> Hi, Nick.
>
> > I didn't like the difference between $ and @ though, they could be the
> > same
> > thing really, like:
> > {section}
> > <td>$articleTitle</td>
> > <td>$articleDate</td>
> > {/section}
> >
> > How would it be differently used.
>
> This is how we tried to do it originally. One of the problems with this
> approach is that the engine would need to detect at run-time which
> variables have multiple values so that it knows that it needs to loop
> through them instead of simply printing out the value. Anything done at
> run-time is slower, of course. Another reason we thought @ would be nice
> is because it's visually clear which variables have multiple values and
> are being looped through (@ looks like a loop).
>
> > There is one thing I would like shown to me though. If I want to skip
> > tags
> > when a value is empty, how would this be. Is this the only way:
> > {if $value}
> > $value<br>
> > {/if}
> >
> > would be nicer to link the tag to the var somehow, like:
> > {$value{<br>}}
> > but maybe some better syntax.
>
> If it's a looping variable, you can do this:
>
> {section}@value<br>{/section}
>
This just answered your first question :-) Only looping variables affect
section collapsing, so there needs to be a distinction between looping
and single-value variables. That is why "$" and "@" were introduced.
Maybe there is a better way?
> because sections automatically collapse if variables inside them have no
> values.
>
> > Also how would a blank value be changed to for example, can you
> > define defaults for a value somehow, e.g.:
> > {$value default=" "}
>
> Once again, you'd probably want to do this only for looping variables,
> when they run out of values. For single value variables, it wouldn't be
> too useful. Unless you have a good example?
>
And to answer your question, variables can have a default value
attribute just like your example. See the specs.
Monte