Re: [PHP Template] dynamic blocks

[email protected] (Monte Ohrt)
Newsgroups php.template
Organization ispi
Message-ID <[email protected]>
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:
&#123;Title&#125;
</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
>
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.