more livedocs fixes

This commit is contained in:
didou
2004-03-30 09:35:30 +00:00
parent 8cef1056f8
commit a7a2083afc
4 changed files with 57 additions and 27 deletions

View File

@@ -233,13 +233,14 @@ Pretty easy isn't it?
You can embed PHP into your templates with the {php}{/php} tags. You can embed PHP into your templates with the {php}{/php} tags.
With this, you can setup self contained templates with their own With this, you can setup self contained templates with their own
data structures for assigning their own variables. With the logic data structures for assigning their own variables. With the logic
embedded like this, you can keep the template & logic together. This embedded like this, you can keep the template & logic together. This
way no matter where the template source is coming from, it is always way no matter where the template source is coming from, it is always
together as one component. together as one component.
</para> </para>
<example> <example>
<title>componentized template</title> <title>componentized template</title>
<programlisting> <programlisting>
<![CDATA[
{* Smarty *} {* Smarty *}
{php} {php}
@@ -259,7 +260,8 @@ Pretty easy isn't it?
{/php} {/php}
Stock Name: {$ticker_name} Stock Price: {$ticker_price}</programlisting> Stock Name: {$ticker_name} Stock Price: {$ticker_price}
]]></programlisting>
</example> </example>
<para> <para>
As of Smarty 1.5.0, there is even a cleaner way. You can include php in As of Smarty 1.5.0, there is even a cleaner way. You can include php in
@@ -271,6 +273,7 @@ Stock Name: {$ticker_name} Stock Price: {$ticker_price}</programlisting>
<example> <example>
<title>componentized template with include_php</title> <title>componentized template with include_php</title>
<programlisting> <programlisting>
<![CDATA[
load_ticker.php load_ticker.php
--------------- ---------------
@@ -297,7 +300,8 @@ index.tpl
{include_php file="load_ticker.php"} {include_php file="load_ticker.php"}
Stock Name: {$ticker_name} Stock Price: {$ticker_price}</programlisting> Stock Name: {$ticker_name} Stock Price: {$ticker_price}
]]></programlisting>
</example> </example>
</sect1> </sect1>
<sect1 id="tips.obfuscating.email"> <sect1 id="tips.obfuscating.email">

View File

@@ -683,6 +683,7 @@ index.tpl
<example> <example>
<title><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> if</title> <title><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> if</title>
<programlisting> <programlisting>
<![CDATA[
{if $name eq "Fred"} {if $name eq "Fred"}
Welcome Sir. Welcome Sir.
{elseif $name eq "Wilma"} {elseif $name eq "Wilma"}
@@ -743,7 +744,9 @@ index.tpl
{* 0=<3D><><EFBFBD><EFBFBD><EFBFBD>, 1=<3D><><EFBFBD><EFBFBD><EFBFBD>, 2=<3D><><EFBFBD><EFBFBD><EFBFBD>, 3=<3D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, 4=<3D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, 5=<3D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20> <20>.<2E>. *} {* 0=<3D><><EFBFBD><EFBFBD><EFBFBD>, 1=<3D><><EFBFBD><EFBFBD><EFBFBD>, 2=<3D><><EFBFBD><EFBFBD><EFBFBD>, 3=<3D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, 4=<3D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, 5=<3D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20> <20>.<2E>. *}
{if $var is even by 3} {if $var is even by 3}
... ...
{/if}</programlisting> {/if}
]]>
</programlisting>
</example> </example>
</sect1> </sect1>
<sect1 id="language.function.ldelim"> <sect1 id="language.function.ldelim">

View File

@@ -91,7 +91,8 @@ the output was {$output)
<example> <example>
<title>using a template prefilter</title> <title>using a template prefilter</title>
<programlisting> <programlisting>
&lt;?php <![CDATA[
<?php
// put this in your application // put this in your application
function remove_dw_comments($tpl_source, &$smarty) function remove_dw_comments($tpl_source, &$smarty)
{ {
@@ -101,10 +102,11 @@ function remove_dw_comments($tpl_source, &$smarty)
// register the prefilter // register the prefilter
$smarty->register_prefilter("remove_dw_comments"); $smarty->register_prefilter("remove_dw_comments");
$smarty->display("index.tpl"); $smarty->display("index.tpl");
?&gt; ?>
{* Smarty template index.tpl *} {* Smarty template index.tpl *}
&lt;!--# this line will get removed by the prefilter --&gt;</programlisting> &lt;!--# this line will get removed by the prefilter --&gt;
]]></programlisting>
</example> </example>
</sect1> </sect1>
@@ -125,6 +127,7 @@ $smarty->display("index.tpl");
<example> <example>
<title>using a template postfilter</title> <title>using a template postfilter</title>
<programlisting> <programlisting>
<![CDATA[
&lt;?php &lt;?php
// put this in your application // put this in your application
function add_header_comment($tpl_source, &$smarty) function add_header_comment($tpl_source, &$smarty)
@@ -139,7 +142,9 @@ $smarty->display("index.tpl");
{* compiled Smarty template index.tpl *} {* compiled Smarty template index.tpl *}
&lt;!-- Created by Smarty! --&gt; &lt;!-- Created by Smarty! --&gt;
{* rest of template content... *}</programlisting> {* rest of template content... *}
]]>
</programlisting>
</example> </example>
</sect1> </sect1>
@@ -166,6 +171,7 @@ $smarty->display("index.tpl");
<example> <example>
<title>using a template outputfilter</title> <title>using a template outputfilter</title>
<programlisting> <programlisting>
<![CDATA[
&lt;?php &lt;?php
// put this in your application // put this in your application
function protect_email($tpl_output, &$smarty) function protect_email($tpl_output, &$smarty)
@@ -182,7 +188,8 @@ $smarty->display("index.tpl");
// now any occurrence of an email address in the template output will have // now any occurrence of an email address in the template output will have
// a simple protection against spambots // a simple protection against spambots
?&gt;</programlisting> ?&gt;
]]></programlisting>
</example> </example>
</sect1> </sect1>
@@ -211,6 +218,7 @@ $smarty->display("index.tpl");
<example> <example>
<title>example using MySQL as a cache source</title> <title>example using MySQL as a cache source</title>
<programlisting> <programlisting>
<![CDATA[
&lt;?php &lt;?php
/* /*
@@ -312,7 +320,8 @@ function mysql_cache_handler($action, &$smarty_obj, &$cache_content, $tpl_file=n
} }
?&gt;</programlisting> ?&gt;
]]></programlisting>
</example> </example>
</sect1> </sect1>
@@ -410,6 +419,7 @@ $smarty->display("file:F:/path/to/my/templates/menu.tpl");
<example> <example>
<title>using custom resources</title> <title>using custom resources</title>
<programlisting> <programlisting>
<![CDATA[
// from PHP script // from PHP script
// put these function somewhere in your application // put these function somewhere in your application
@@ -465,7 +475,8 @@ $smarty->register_resource("db", array("db_get_template",
$smarty->display("db:index.tpl"); $smarty->display("db:index.tpl");
{* using resource from within Smarty template *} {* using resource from within Smarty template *}
{include file="db:/extras/navigation.tpl"}</programlisting> {include file="db:/extras/navigation.tpl"}
]]></programlisting>
</example> </example>
</sect2> </sect2>

View File

@@ -324,7 +324,7 @@ function smarty_modifier_truncate($string, $length = 80, $etc = '...',
<funcdef>void <function>smarty_block_<replaceable>name</replaceable></function></funcdef> <funcdef>void <function>smarty_block_<replaceable>name</replaceable></function></funcdef>
<paramdef>array <parameter>$params</parameter></paramdef> <paramdef>array <parameter>$params</parameter></paramdef>
<paramdef>mixed <parameter>$content</parameter></paramdef> <paramdef>mixed <parameter>$content</parameter></paramdef>
<paramdef>object <parameter>&$smarty</parameter></paramdef> <paramdef>object <parameter>&amp;$smarty</parameter></paramdef>
</funcprototype> </funcprototype>
</funcsynopsis> </funcsynopsis>
<para> <para>
@@ -404,7 +404,7 @@ function smarty_block_translate($params, $content, &amp;$smarty)
<funcprototype> <funcprototype>
<funcdef>mixed <function>smarty_compiler_<replaceable>name</replaceable></function></funcdef> <funcdef>mixed <function>smarty_compiler_<replaceable>name</replaceable></function></funcdef>
<paramdef>string <parameter>$tag_arg</parameter></paramdef> <paramdef>string <parameter>$tag_arg</parameter></paramdef>
<paramdef>object <parameter>&$smarty</parameter></paramdef> <paramdef>object <parameter>&amp;$smarty</parameter></paramdef>
</funcprototype> </funcprototype>
</funcsynopsis> </funcsynopsis>
<para> <para>
@@ -421,6 +421,7 @@ function smarty_block_translate($params, $content, &amp;$smarty)
<example> <example>
<title>simple compiler function</title> <title>simple compiler function</title>
<programlisting> <programlisting>
<![CDATA[
&lt;?php &lt;?php
/* /*
* Smarty plugin * Smarty plugin
@@ -436,7 +437,8 @@ function smarty_compiler_tplheader($tag_arg, &$smarty)
{ {
return "\necho '" . $smarty-&gt;_current_file . " compiled at " . date('Y-m-d H:M'). "';"; return "\necho '" . $smarty-&gt;_current_file . " compiled at " . date('Y-m-d H:M'). "';";
} }
?&gt;</programlisting> ?&gt;
]]></programlisting>
<para> <para>
This function can be called from the template as: This function can be called from the template as:
</para> </para>
@@ -464,7 +466,7 @@ echo 'index.tpl compiled at 2002-02-20 20:02';
<funcprototype> <funcprototype>
<funcdef>string <function>smarty_prefilter_<replaceable>name</replaceable></function></funcdef> <funcdef>string <function>smarty_prefilter_<replaceable>name</replaceable></function></funcdef>
<paramdef>string <parameter>$source</parameter></paramdef> <paramdef>string <parameter>$source</parameter></paramdef>
<paramdef>object <parameter>&$smarty</parameter></paramdef> <paramdef>object <parameter>&amp;$smarty</parameter></paramdef>
</funcprototype> </funcprototype>
</funcsynopsis> </funcsynopsis>
<para> <para>
@@ -478,7 +480,7 @@ echo 'index.tpl compiled at 2002-02-20 20:02';
<funcprototype> <funcprototype>
<funcdef>string <function>smarty_postfilter_<replaceable>name</replaceable></function></funcdef> <funcdef>string <function>smarty_postfilter_<replaceable>name</replaceable></function></funcdef>
<paramdef>string <parameter>$compiled</parameter></paramdef> <paramdef>string <parameter>$compiled</parameter></paramdef>
<paramdef>object <parameter>&$smarty</parameter></paramdef> <paramdef>object <parameter>&amp;$smarty</parameter></paramdef>
</funcprototype> </funcprototype>
</funcsynopsis> </funcsynopsis>
<para> <para>
@@ -492,6 +494,7 @@ echo 'index.tpl compiled at 2002-02-20 20:02';
<example> <example>
<title>prefilter plugin</title> <title>prefilter plugin</title>
<programlisting> <programlisting>
<![CDATA[
&lt;?php &lt;?php
/* /*
* Smarty plugin * Smarty plugin
@@ -506,12 +509,15 @@ echo 'index.tpl compiled at 2002-02-20 20:02';
{ {
return preg_replace('!&lt;(\w+)[^&gt;]+&gt;!e', 'strtolower("$1")', $source); return preg_replace('!&lt;(\w+)[^&gt;]+&gt;!e', 'strtolower("$1")', $source);
} }
?&gt;</programlisting> ?&gt;
]]>
</programlisting>
</example> </example>
<para></para> <para></para>
<example> <example>
<title>postfilter plugin</title> <title>postfilter plugin</title>
<programlisting> <programlisting>
<![CDATA[
&lt;?php &lt;?php
/* /*
* Smarty plugin * Smarty plugin
@@ -527,7 +533,9 @@ echo 'index.tpl compiled at 2002-02-20 20:02';
$compiled = "&lt;pre&gt;\n&lt;?php print_r(\$this-&gt;get_template_vars()); ?&gt;\n&lt;/pre&gt;" . $compiled; $compiled = "&lt;pre&gt;\n&lt;?php print_r(\$this-&gt;get_template_vars()); ?&gt;\n&lt;/pre&gt;" . $compiled;
return $compiled; return $compiled;
} }
?&gt;</programlisting> ?&gt;
]]>
</programlisting>
</example> </example>
</sect1> </sect1>
@@ -540,7 +548,7 @@ echo 'index.tpl compiled at 2002-02-20 20:02';
<funcprototype> <funcprototype>
<funcdef>string <function>smarty_outputfilter_<replaceable>name</replaceable></function></funcdef> <funcdef>string <function>smarty_outputfilter_<replaceable>name</replaceable></function></funcdef>
<paramdef>string <parameter>$template_output</parameter></paramdef> <paramdef>string <parameter>$template_output</parameter></paramdef>
<paramdef>object <parameter>&$smarty</parameter></paramdef> <paramdef>object <parameter>&amp;$smarty</parameter></paramdef>
</funcprototype> </funcprototype>
</funcsynopsis> </funcsynopsis>
<para> <para>
@@ -551,7 +559,9 @@ echo 'index.tpl compiled at 2002-02-20 20:02';
</para> </para>
<example> <example>
<title>output filter plugin</title> <title>output filter plugin</title>
<programlisting> <programlisting role="php">
<![CDATA[
<?php
/* /*
* Smarty plugin * Smarty plugin
* ------------------------------------------------------------- * -------------------------------------------------------------
@@ -567,6 +577,8 @@ echo 'index.tpl compiled at 2002-02-20 20:02';
return preg_replace('!(\S+)@([a-zA-Z0-9\.\-]+\.([a-zA-Z]{2,3}|[0-9]{1,3}))!', return preg_replace('!(\S+)@([a-zA-Z0-9\.\-]+\.([a-zA-Z]{2,3}|[0-9]{1,3}))!',
'$1%40$2', $output); '$1%40$2', $output);
} }
?>
]]>
</programlisting> </programlisting>
</example> </example>
</sect1> </sect1>
@@ -589,24 +601,24 @@ echo 'index.tpl compiled at 2002-02-20 20:02';
<funcprototype> <funcprototype>
<funcdef>bool <function>smarty_resource_<replaceable>name</replaceable>_source</function></funcdef> <funcdef>bool <function>smarty_resource_<replaceable>name</replaceable>_source</function></funcdef>
<paramdef>string <parameter>$rsrc_name</parameter></paramdef> <paramdef>string <parameter>$rsrc_name</parameter></paramdef>
<paramdef>string <parameter>&$source</parameter></paramdef> <paramdef>string <parameter>&amp;$source</parameter></paramdef>
<paramdef>object <parameter>&$smarty</parameter></paramdef> <paramdef>object <parameter>&amp;$smarty</parameter></paramdef>
</funcprototype> </funcprototype>
<funcprototype> <funcprototype>
<funcdef>bool <function>smarty_resource_<replaceable>name</replaceable>_timestamp</function></funcdef> <funcdef>bool <function>smarty_resource_<replaceable>name</replaceable>_timestamp</function></funcdef>
<paramdef>string <parameter>$rsrc_name</parameter></paramdef> <paramdef>string <parameter>$rsrc_name</parameter></paramdef>
<paramdef>int <parameter>&$timestamp</parameter></paramdef> <paramdef>int <parameter>&amp;$timestamp</parameter></paramdef>
<paramdef>object <parameter>&$smarty</parameter></paramdef> <paramdef>object <parameter>&amp;$smarty</parameter></paramdef>
</funcprototype> </funcprototype>
<funcprototype> <funcprototype>
<funcdef>bool <function>smarty_resource_<replaceable>name</replaceable>_secure</function></funcdef> <funcdef>bool <function>smarty_resource_<replaceable>name</replaceable>_secure</function></funcdef>
<paramdef>string <parameter>$rsrc_name</parameter></paramdef> <paramdef>string <parameter>$rsrc_name</parameter></paramdef>
<paramdef>object <parameter>&$smarty</parameter></paramdef> <paramdef>object <parameter>&amp;$smarty</parameter></paramdef>
</funcprototype> </funcprototype>
<funcprototype> <funcprototype>
<funcdef>bool <function>smarty_resource_<replaceable>name</replaceable>_trusted</function></funcdef> <funcdef>bool <function>smarty_resource_<replaceable>name</replaceable>_trusted</function></funcdef>
<paramdef>string <parameter>$rsrc_name</parameter></paramdef> <paramdef>string <parameter>$rsrc_name</parameter></paramdef>
<paramdef>object <parameter>&$smarty</parameter></paramdef> <paramdef>object <parameter>&amp;$smarty</parameter></paramdef>
</funcprototype> </funcprototype>
</funcsynopsis> </funcsynopsis>
@@ -716,7 +728,7 @@ function smarty_resource_db_trusted($tpl_name, &amp;$smarty)
<funcprototype> <funcprototype>
<funcdef>string <function>smarty_insert_<replaceable>name</replaceable></function></funcdef> <funcdef>string <function>smarty_insert_<replaceable>name</replaceable></function></funcdef>
<paramdef>array <parameter>$params</parameter></paramdef> <paramdef>array <parameter>$params</parameter></paramdef>
<paramdef>object <parameter>&$smarty</parameter></paramdef> <paramdef>object <parameter>&amp;$smarty</parameter></paramdef>
</funcprototype> </funcprototype>
</funcsynopsis> </funcsynopsis>
<para> <para>