Re: [PHP Template] dynamic blocks
| From: | Monte Ohrt | Date: | Wed, 16 Feb 2000 20:14:59 +0000 |
| Subject: | Re: [PHP Template] dynamic blocks | ||
| References: | 1 2 | Groups: | php.template |
| Request: | Send a blank email to php-template+get-90@lists.php.net to get a copy of this message | ||
There are lots of ways to escape the dollar,
maybe with a backslash:
<if $title != "foo">
<b>$title</b> is \$5.00
</if>
With curly braces, how does one print a literal word in
curly braces without interpreting this as a template var? For
instance, a web page that explains how PHP templates work:
<B>
To put variables in templates, use curly braces like so:
\{Title\}
</B>
You could use html special characters like this:
<B>
To put variables in templates, use curly braces like so:
{Title}
</B>
but then that only works on a browser. Remember that
PHP templates can be used to create other documents,
such as outgoing e-mail. In that case, using html
special chars doesn't work well.
Here are a couple of examples for comparison
I threw the loop:row thing in to possibly spark more ideas.
I also got rid of the colon in the template tags, and
added an attribute "name" to the dynamic function. That
will allow us other attributes in the future.
<!-- example #1 -->
<HTML>
<BODY>
<IF $title != "">
<TITLE>$title</TITLE>
<ELSE>
<TITLE>none</TITLE>
</IF>
<TABLE border=0>
<DYNAMIC name=row>
<TR>
<TD>$cellcontent</TD>
</TR>
</DYNAMIC>
There were $loop:row results.
</TABLE>
</BODY>
</HTML>
<!-- example #2 -->
<HTML>
<BODY>
<IF {title} != "">
<TITLE>{title}</TITLE>
<ELSE>
<TITLE>none</TITLE>
</IF>
<TABLE border=0>
<DYNAMIC name=row>
<TR>
<TD>{cellcontent}</TD>
</TR>
</DYNAMIC>
There were {loop:row} results.
</TABLE>
</BODY>
</HTML>
Monte
Sanford Redlich wrote:
>
> I like Monte's option #2, with the curly braces (the $$ thing could lead to
> mistakes that might be confusing to the designer if s/he forgot to use two
> dollar signs).
>
> Sanford
>