Re: [PHP Template] Re: [PHP3] Re: [PHP Template] Template Discussion
[email protected] (Monte Ohrt) Wed, 22 Mar 2000 14:51:52 -0600
| Newsgroups | php.template |
|---|---|
| Organization | ispi |
| Message-ID | <[email protected]> |
Hi Andi,
Andi Gutmans wrote:
>
> Do you really feel that learning:
> {if "foo" == "bar"}
> ...
> {/if}
>
> is so much easier for you then:
> <? if ("foo" == "bar"): ?>
> ...
> <? endif; ?>
>
> I can't believe that if you have the ability to learn the first
> conditional you can't learn the second one.
>
> They are the same.
>
> Andi
>
This example you give here isn't all that bad. But let's take a look at
section looping:
{section}
{@Name}<br>
{@Address}<br>
{@Phone}<p>
{/section}
In the template spec, "@" variables a visual indication of arrays that
are looped, determined by the number of elements in the array. This is
all automatic in the template. The programmer assigns the values to the
array, and the designer uses them in the section. To do this in PHP, it
would look something like:
<? for($loop=0; $loop<=count($Name); $loop++): ?>
<? print $Name[$loop]; ?><br>
<? print $Name[$loop]; ?><br>
<? print $Name[$loop]; ?><p>
<? endfor; ?>
this introduces for() loops, whereas looping is implicit in the current
template spec. The spec also has automated ways of taking care of uneven
arrays, default variable values, etc... all which would have to be coded
explicitly in this PHP code fashion. Our intent is to take the
tediousness out of the template, automating common layout tasks as much
as possible.