fixing some more examples

This commit is contained in:
nlopess
2004-03-24 17:11:28 +00:00
parent 7e71a93dca
commit 4e43457329
2 changed files with 47 additions and 47 deletions

View File

@@ -58,26 +58,26 @@ Parse error: parse error in /path/to/smarty/templates_c/index.tpl.php on line 75
</sect1> </sect1>
</chapter> </chapter>
<chapter id="tips"> <chapter id="tips">
<title>Tips &amp; Tricks</title> <title>Tips & Tricks</title>
<para> <para>
</para> </para>
<sect1 id="tips.blank.var.handling"> <sect1 id="tips.blank.var.handling">
<title>Blank Variable Handling</title> <title>Blank Variable Handling</title>
<para> <para>
There may be times when you want to print a default value for an empty There may be times when you want to print a default value for an empty
variable instead of printing nothing, such as printing "&amp;nbsp;" so that variable instead of printing nothing, such as printing "&nbsp;" so that
table backgrounds work properly. Many would use an {if} statement to table backgrounds work properly. Many would use an {if} statement to
handle this, but there is a shorthand way with Smarty, using the handle this, but there is a shorthand way with Smarty, using the
<emphasis>default</emphasis> variable modifier. <emphasis>default</emphasis> variable modifier.
</para> </para>
<example> <example>
<title>Printing &amp;nbsp; when a variable is empty</title> <title>Printing &nbsp; when a variable is empty</title>
<programlisting> <programlisting>
<![CDATA[ <![CDATA[
{* the long way *} {* the long way *}
{if $title eq ""} {if $title eq ""}
&amp;nbsp; &nbsp;
{else} {else}
{$title} {$title}
{/if} {/if}
@@ -85,7 +85,7 @@ Parse error: parse error in /path/to/smarty/templates_c/index.tpl.php on line 75
{* the short way *} {* the short way *}
{$title|default:"&amp;nbsp;"} {$title|default:"&nbsp;"}
]]> ]]>
</programlisting> </programlisting>
</example> </example>
@@ -144,17 +144,17 @@ archives.tpl
header.tpl header.tpl
---------- ----------
&lt;HTML&gt; <HTML>
&lt;HEAD&gt; <HEAD>
&lt;TITLE&gt;{$title|default:"BC News"}&lt;/TITLE&gt; <TITLE>{$title|default:"BC News"}</TITLE>
&lt;/HEAD&gt; </HEAD>
&lt;BODY&gt; <BODY>
footer.tpl footer.tpl
---------- ----------
&lt;/BODY&gt; </BODY>
&lt;/HTML&gt; </HTML>
]]> ]]>
</programlisting> </programlisting>
</example> </example>
@@ -199,7 +199,7 @@ OUTPUT:
2001/01/04 2001/01/04
{if $date1 &lt; $date2} {if $date1 < $date2}
... ...
{/if} {/if}
]]> ]]>
@@ -270,28 +270,28 @@ function insert_header($params) {
<![CDATA[ <![CDATA[
{insert name=header content="Content-Type: text/vnd.wap.wml"} {insert name=header content="Content-Type: text/vnd.wap.wml"}
&lt;?xml version="1.0"?&gt; <?xml version="1.0"?>
&lt;!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml"&gt; <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
&lt;!-- begin new wml deck --&gt; <!-- begin new wml deck -->
&lt;wml&gt; <wml>
&lt;!-- begin first card --&gt; <!-- begin first card -->
&lt;card&gt; <card>
&lt;do type="accept"&gt; <do type="accept">
&lt;go href="#two"/&gt; <go href="#two"/>
&lt;/do&gt; </do>
&lt;p&gt; <p>
Welcome to WAP with Smarty! Welcome to WAP with Smarty!
Press OK to continue... Press OK to continue...
&lt;/p&gt; </p>
&lt;/card&gt; </card>
&lt;!-- begin second card --&gt; <!-- begin second card -->
&lt;card id="two"&gt; <card id="two">
&lt;p&gt; <p>
Pretty easy isn't it? Pretty easy isn't it?
&lt;/p&gt; </p>
&lt;/card&gt; </card>
&lt;/wml&gt; </wml>
]]> ]]>
</programlisting> </programlisting>
</example> </example>
@@ -328,7 +328,7 @@ function fetch_ticker($symbol) {
return $ticker_info; return $ticker_info;
} }
function smarty_function_load_ticker($params, &amp;$smarty) { function smarty_function_load_ticker($params, &$smarty) {
// call the function // call the function
$ticker_info = fetch_ticker($params['symbol']); $ticker_info = fetch_ticker($params['symbol']);

View File

@@ -1069,7 +1069,7 @@ index.tpl:
{$articleTitle} {$articleTitle}
{$articleTitle|escape} {$articleTitle|escape}
{$articleTitle|escape:"html"} {* escapes &amp; &quot; &#039; &lt; &gt; *} {$articleTitle|escape:"html"} {* escapes & &quot; &#039; &lt; &gt; *}
{$articleTitle|escape:"htmlall"} {* escapes ALL html entities *} {$articleTitle|escape:"htmlall"} {* escapes ALL html entities *}
{$articleTitle|escape:"url"} {$articleTitle|escape:"url"}
{$articleTitle|escape:"quotes"} {$articleTitle|escape:"quotes"}
@@ -1078,12 +1078,12 @@ index.tpl:
OUTPUT: OUTPUT:
'Stiff Opposition Expected to Casketless Funeral Plan' 'Stiff Opposition Expected to Casketless Funeral Plan'
&amp;#039;Stiff Opposition Expected to Casketless Funeral Plan&amp;#039; &#039;Stiff Opposition Expected to Casketless Funeral Plan&#039;
&amp;#039;Stiff Opposition Expected to Casketless Funeral Plan&amp;#039; &#039;Stiff Opposition Expected to Casketless Funeral Plan&#039;
&amp;#039;Stiff Opposition Expected to Casketless Funeral Plan&amp;#039; &#039;Stiff Opposition Expected to Casketless Funeral Plan&#039;
%27Stiff+Opposition+Expected+to+Casketless+Funeral+Plan%27 %27Stiff+Opposition+Expected+to+Casketless+Funeral+Plan%27
\'Stiff Opposition Expected to Casketless Funeral Plan\' \'Stiff Opposition Expected to Casketless Funeral Plan\'
&lt;a href=&quot;mailto:%62%6f%62%40%6d%65%2e%6e%65%74&quot;&gt;&amp;#x62;&amp;#x6f;&amp;#x62;&amp;#x40;&amp;#x6d;&amp;#x65;&amp;#x2e;&amp;#x6e;&amp;#x65;&amp;#x74;&lt;/a&gt;</programlisting> &lt;a href=&quot;mailto:%62%6f%62%40%6d%65%2e%6e%65%74&quot;&gt;&#x62;&#x6f;&#x62;&#x40;&#x6d;&#x65;&#x2e;&#x6e;&#x65;&#x74;&lt;/a&gt;</programlisting>
</example> </example>
</sect1> </sect1>
<sect1 id="language.modifier.indent"> <sect1 id="language.modifier.indent">
@@ -1267,7 +1267,7 @@ $smarty-&gt;display('index.tpl');
index.tpl: index.tpl:
{* replace each carriage return, tab &amp; new line with a space *} {* replace each carriage return, tab & new line with a space *}
{$articleTitle} {$articleTitle}
{$articleTitle|regex_replace:"/[\r\t\n]/":" "} {$articleTitle|regex_replace:"/[\r\t\n]/":" "}
@@ -1477,14 +1477,14 @@ index.tpl:
{$articleTitle} {$articleTitle}
{$articleTitle|strip} {$articleTitle|strip}
{$articleTitle|strip:"&amp;nbsp;"} {$articleTitle|strip:"&nbsp;"}
OUTPUT: OUTPUT:
Grandmother of Grandmother of
eight makes hole in one. eight makes hole in one.
Grandmother of eight makes hole in one. Grandmother of eight makes hole in one.
Grandmother&amp;nbsp;of&amp;nbsp;eight&amp;nbsp;makes&amp;nbsp;hole&amp;nbsp;in&amp;nbsp;one.</programlisting> Grandmother&nbsp;of&nbsp;eight&nbsp;makes&nbsp;hole&nbsp;in&nbsp;one.</programlisting>
</example> </example>
</sect1> </sect1>
<sect1 id="language.modifier.strip.tags"> <sect1 id="language.modifier.strip.tags">
@@ -2480,7 +2480,7 @@ index.tpl
<emphasis>{/if}</emphasis>. <emphasis>{else}</emphasis> and <emphasis>{/if}</emphasis>. <emphasis>{else}</emphasis> and
<emphasis>{elseif}</emphasis> are also permitted. All PHP conditionals <emphasis>{elseif}</emphasis> are also permitted. All PHP conditionals
are recognized, such as <emphasis>||</emphasis>, <emphasis>or</emphasis>, are recognized, such as <emphasis>||</emphasis>, <emphasis>or</emphasis>,
<emphasis>&amp;&amp;</emphasis>, <emphasis>and</emphasis>, etc. <emphasis>&&</emphasis>, <emphasis>and</emphasis>, etc.
</para> </para>
<para> <para>
@@ -3731,7 +3731,7 @@ index.tpl
OUTPUT: OUTPUT:
This is the contents of foo. This is the contents of foo.
Welcome to Foobar Pub &amp; Grill's home page! Welcome to Foobar Pub & Grill's home page!
You must supply a &lt;b&gt;city&lt;/b&gt;. You must supply a &lt;b&gt;city&lt;/b&gt;.
You must supply a &lt;b&gt;state&lt;/b&gt;. You must supply a &lt;b&gt;state&lt;/b&gt;.
@@ -5007,7 +5007,7 @@ OUTPUT:
<entry>trailpad</entry> <entry>trailpad</entry>
<entry>string</entry> <entry>string</entry>
<entry>No</entry> <entry>No</entry>
<entry><emphasis>&amp;nbsp;</emphasis></entry> <entry><emphasis>&nbsp;</emphasis></entry>
<entry>value to pad the trailing cells on last row with <entry>value to pad the trailing cells on last row with
(if any)</entry> (if any)</entry>
</row> </row>
@@ -5067,12 +5067,12 @@ OUTPUT:
&lt;table border="0"&gt; &lt;table border="0"&gt;
&lt;tr&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;3&lt;/td&gt;&lt;td&gt;4&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;3&lt;/td&gt;&lt;td&gt;4&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;5&lt;/td&gt;&lt;td&gt;6&lt;/td&gt;&lt;td&gt;7&lt;/td&gt;&lt;td&gt;8&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;5&lt;/td&gt;&lt;td&gt;6&lt;/td&gt;&lt;td&gt;7&lt;/td&gt;&lt;td&gt;8&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;9&lt;/td&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;9&lt;/td&gt;&lt;td&gt;&nbsp;&lt;/td&gt;&lt;td&gt;&nbsp;&lt;/td&gt;&lt;td&gt;&nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt; &lt;/table&gt;
&lt;table border="1"&gt; &lt;table border="1"&gt;
&lt;tr bgcolor="#eeeeee"&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;3&lt;/td&gt;&lt;td&gt;4&lt;/td&gt;&lt;/tr&gt; &lt;tr bgcolor="#eeeeee"&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;3&lt;/td&gt;&lt;td&gt;4&lt;/td&gt;&lt;/tr&gt;
&lt;tr bgcolor="#dddddd"&gt;&lt;td&gt;5&lt;/td&gt;&lt;td&gt;6&lt;/td&gt;&lt;td&gt;7&lt;/td&gt;&lt;td&gt;8&lt;/td&gt;&lt;/tr&gt; &lt;tr bgcolor="#dddddd"&gt;&lt;td&gt;5&lt;/td&gt;&lt;td&gt;6&lt;/td&gt;&lt;td&gt;7&lt;/td&gt;&lt;td&gt;8&lt;/td&gt;&lt;/tr&gt;
&lt;tr bgcolor="#eeeeee"&gt;&lt;td&gt;9&lt;/td&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt; &lt;tr bgcolor="#eeeeee"&gt;&lt;td&gt;9&lt;/td&gt;&lt;td&gt;&nbsp;&lt;/td&gt;&lt;td&gt;&nbsp;&lt;/td&gt;&lt;td&gt;&nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</programlisting> &lt;/table&gt;</programlisting>
</example> </example>
</sect1> </sect1>
@@ -5325,8 +5325,8 @@ OUTPUT:
9%74%65%28%27%3c%61%20%68%72%65%66%3d%22%6d%61%69%6c%74%6f%3a%6d%65%40%64%6f%6d% 9%74%65%28%27%3c%61%20%68%72%65%66%3d%22%6d%61%69%6c%74%6f%3a%6d%65%40%64%6f%6d%
61%69%6e%2e%63%6f%6d%22%20%3e%6d%65%40%64%6f%6d%61%69%6e%2e%63%6f%6d%3c%2f%61%3e 61%69%6e%2e%63%6f%6d%22%20%3e%6d%65%40%64%6f%6d%61%69%6e%2e%63%6f%6d%3c%2f%61%3e
%27%29%3b'))&lt;/script&gt; %27%29%3b'))&lt;/script&gt;
&lt;a href="mailto:%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d" &gt;&amp;#x6d;&amp;#x65;&amp;#x40;&amp;#x64;&amp; &lt;a href="mailto:%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d" &gt;&#x6d;&#x65;&#x40;&#x64;&
#x6f;&amp;#x6d;&amp;#x61;&amp;#x69;&amp;#x6e;&amp;#x2e;&amp;#x63;&amp;#x6f;&amp;#x6d;&lt;/a&gt; #x6f;&#x6d;&#x61;&#x69;&#x6e;&#x2e;&#x63;&#x6f;&#x6d;&lt;/a&gt;
&lt;a href="mailto:me@domain.com?subject=Hello%20to%20you%21" &gt;me@domain.com&lt;/a&gt; &lt;a href="mailto:me@domain.com?subject=Hello%20to%20you%21" &gt;me@domain.com&lt;/a&gt;
&lt;a href="mailto:me@domain.com?cc=you@domain.com%2Cthey@domain.com" &gt;me@domain.com&lt;/a&gt; &lt;a href="mailto:me@domain.com?cc=you@domain.com%2Cthey@domain.com" &gt;me@domain.com&lt;/a&gt;
&lt;a href="mailto:me@domain.com" class="email"&gt;me@domain.com&lt;/a&gt;</programlisting> &lt;a href="mailto:me@domain.com" class="email"&gt;me@domain.com&lt;/a&gt;</programlisting>