Re: [PHP Template] dynamic blocks

[email protected] (Monte Ohrt)
Newsgroups php.template
Organization ispi
Message-ID <[email protected]>
Andrei Zmievski wrote:
> 
> On Wed, 16 Feb 2000, Monte Ohrt wrote:
> > It would probably work without the braces, but then you have two
> > separate formats of your variables in the template. We have a better
> > consistancy in that regard with this format:
> >
> > {if: $title != "foo"}
> >     <b>$title</b>
> > {else:}
> >     <b>none</b>
> > {/if}
> 
> Actually, I'm starting to think that having $ in front of variables is
> better. {{$varname}} would print the variable, and then you can refer to
> them in if statements in the same manner.
> 
> What does everyone think about consistency of using : to delimit
> commands? In the above example there is : after 'else' but not after
> '/if', is that OK? Should 'else' not have :?
> 
> What about named attributes for commands, i.e.
> {{section: name = header}} instead of {{section: header}}?
> 
> -Andrei

I like the idea of attributes, it keeps the template syntax flexible.

It looks like we're kind of using colon as a way to recognize
logic elements of the template, much the same way Zope prepends
"dtml-" to everything (which is kind of ugly in my opinion.)

Here are some ideas. Whatever we go with, it should be consistant:


{if: $title != "foo"}
  <b>$title</b>
{else:}
  <b>none</b>
{/if:}

{%if $title != "foo"}
  <b>$title</b>
{%else}
  <b>none</b>
{%/if}

{:if $title != "foo"}
  <b>$title</b>
{:else}
  <b>none</b>
{:/if}

{if $title != "foo"}
  <b>$title</b>
{else}
  <b>none</b>
{/if}


After first glance at these, I kind of like the one with a
colon at the end. I'm not sure if the /if and else tags
need colons, but maybe they should for consistancy.

Monte
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.