Re: [PHP3] Re: [PHP Template] Re: [PHP3] Re: [PHP Template] Re:[PHP3] PHP Template Engine spec revision 0.52

[email protected] (Monte Ohrt) Tue, 21 Mar 2000 11:25:31 -0600
Newsgroups php.template
Organization ispi
Message-ID <[email protected]>
Hi Andi,

Andi Gutmans wrote:
> 
> Then just teach them the PHP "if" and "include" commands :) What is the
> use of rewriting these commands for templates?
> 
> Andi

We discussed this, its too messy and terse for your average designer to
easily comprehend. We have found that keeping all logic constructs in
curly braces {} makes the templates much more readable and
understandable to the designer. Our coders and designers are NOT the
same people, thus the demand for templates! The designers are very
visually oriented people, so the templates must resemble the final
output as closely as possible. This doesn't work with PHP style syntax.


Maybe I can do this with an example.

Template using the PHP template engine:


<HTML>
  <HEAD>
    <TITLE>{$PageTitle}</TITLE>
  </HEAD>
  <BODY>
    <TABLE border=0>

       {if $TableHead ne ""}
          <TR>
            <TD colspan=3>{$TableHead}</TD>
          </TR>
       {/if}

       {section}
          <TR>
             <TD>{@Name}</TD>
             <TD>{@Address}</TD>
             <TD>{@Phone}</TD>
          </TR>
       {/section}

    </TABLE>
  </BODY>
</HTML>




No how do you propose the template would look using PHP?


<HTML>
  <HEAD>
    <TITLE><? print $PageTitle; ?></TITLE>
  </HEAD>
  <BODY>
    <TABLE border=0>
       <? if($TableHead != "")
	  { ?>
          <TR>
            <TD colspan=3><? print $TableHead; ?></TD>
          </TR>
          <? }
       for($looprow=0;$looprow<count($Name);$looprow++)
         {
          ?>
          <TR>
             <TD><? print $Name[$looprow]; ?></TD>
             <TD><? print $Address[$looprow]; ?></TD>
             <TD><? print $Phone[$looprow]; ?></TD>
          </TR>
         <?
         }
         ?>
    </TABLE>
  </BODY>
</HTML>


Monte