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.
With this, you can setup self contained templates with their own
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
together as one component.
</para>
<example>
<title>componentized template</title>
<programlisting>
<![CDATA[
{* Smarty *}
{php}
@@ -259,7 +260,8 @@ Pretty easy isn't it?
{/php}
Stock Name: {$ticker_name} Stock Price: {$ticker_price}</programlisting>
Stock Name: {$ticker_name} Stock Price: {$ticker_price}
]]></programlisting>
</example>
<para>
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>
<title>componentized template with include_php</title>
<programlisting>
<![CDATA[
load_ticker.php
---------------
@@ -297,7 +300,8 @@ index.tpl
{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>
</sect1>
<sect1 id="tips.obfuscating.email">

View File

@@ -683,6 +683,7 @@ index.tpl
<example>
<title><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> if</title>
<programlisting>
<![CDATA[
{if $name eq "Fred"}
Welcome Sir.
{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>. *}
{if $var is even by 3}
...
{/if}</programlisting>
{/if}
]]>
</programlisting>
</example>
</sect1>
<sect1 id="language.function.ldelim">

View File

@@ -91,7 +91,8 @@ the output was {$output)
<example>
<title>using a template prefilter</title>
<programlisting>
&lt;?php
<![CDATA[
<?php
// put this in your application
function remove_dw_comments($tpl_source, &$smarty)
{
@@ -101,10 +102,11 @@ function remove_dw_comments($tpl_source, &$smarty)
// register the prefilter
$smarty->register_prefilter("remove_dw_comments");
$smarty->display("index.tpl");
?&gt;
?>
{* 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>
</sect1>
@@ -125,6 +127,7 @@ $smarty->display("index.tpl");
<example>
<title>using a template postfilter</title>
<programlisting>
<![CDATA[
&lt;?php
// put this in your application
function add_header_comment($tpl_source, &$smarty)
@@ -139,7 +142,9 @@ $smarty->display("index.tpl");
{* compiled Smarty template index.tpl *}
&lt;!-- Created by Smarty! --&gt;
{* rest of template content... *}</programlisting>
{* rest of template content... *}
]]>
</programlisting>
</example>
</sect1>
@@ -166,6 +171,7 @@ $smarty->display("index.tpl");
<example>
<title>using a template outputfilter</title>
<programlisting>
<![CDATA[
&lt;?php
// put this in your application
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
// a simple protection against spambots
?&gt;</programlisting>
?&gt;
]]></programlisting>
</example>
</sect1>
@@ -211,6 +218,7 @@ $smarty->display("index.tpl");
<example>
<title>example using MySQL as a cache source</title>
<programlisting>
<![CDATA[
&lt;?php
/*
@@ -312,7 +320,8 @@ function mysql_cache_handler($action, &$smarty_obj, &$cache_content, $tpl_file=n
}
?&gt;</programlisting>
?&gt;
]]></programlisting>
</example>
</sect1>
@@ -410,6 +419,7 @@ $smarty->display("file:F:/path/to/my/templates/menu.tpl");
<example>
<title>using custom resources</title>
<programlisting>
<![CDATA[
// from PHP script
// put these function somewhere in your application
@@ -465,7 +475,8 @@ $smarty->register_resource("db", array("db_get_template",
$smarty->display("db:index.tpl");
{* using resource from within Smarty template *}
{include file="db:/extras/navigation.tpl"}</programlisting>
{include file="db:/extras/navigation.tpl"}
]]></programlisting>
</example>
</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>
<paramdef>array <parameter>$params</parameter></paramdef>
<paramdef>mixed <parameter>$content</parameter></paramdef>
<paramdef>object <parameter>&$smarty</parameter></paramdef>
<paramdef>object <parameter>&amp;$smarty</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
@@ -404,7 +404,7 @@ function smarty_block_translate($params, $content, &amp;$smarty)
<funcprototype>
<funcdef>mixed <function>smarty_compiler_<replaceable>name</replaceable></function></funcdef>
<paramdef>string <parameter>$tag_arg</parameter></paramdef>
<paramdef>object <parameter>&$smarty</parameter></paramdef>
<paramdef>object <parameter>&amp;$smarty</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
@@ -421,6 +421,7 @@ function smarty_block_translate($params, $content, &amp;$smarty)
<example>
<title>simple compiler function</title>
<programlisting>
<![CDATA[
&lt;?php
/*
* 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'). "';";
}
?&gt;</programlisting>
?&gt;
]]></programlisting>
<para>
This function can be called from the template as:
</para>
@@ -464,7 +466,7 @@ echo 'index.tpl compiled at 2002-02-20 20:02';
<funcprototype>
<funcdef>string <function>smarty_prefilter_<replaceable>name</replaceable></function></funcdef>
<paramdef>string <parameter>$source</parameter></paramdef>
<paramdef>object <parameter>&$smarty</parameter></paramdef>
<paramdef>object <parameter>&amp;$smarty</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
@@ -478,7 +480,7 @@ echo 'index.tpl compiled at 2002-02-20 20:02';
<funcprototype>
<funcdef>string <function>smarty_postfilter_<replaceable>name</replaceable></function></funcdef>
<paramdef>string <parameter>$compiled</parameter></paramdef>
<paramdef>object <parameter>&$smarty</parameter></paramdef>
<paramdef>object <parameter>&amp;$smarty</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
@@ -492,6 +494,7 @@ echo 'index.tpl compiled at 2002-02-20 20:02';
<example>
<title>prefilter plugin</title>
<programlisting>
<![CDATA[
&lt;?php
/*
* 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);
}
?&gt;</programlisting>
?&gt;
]]>
</programlisting>
</example>
<para></para>
<example>
<title>postfilter plugin</title>
<programlisting>
<![CDATA[
&lt;?php
/*
* 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;
return $compiled;
}
?&gt;</programlisting>
?&gt;
]]>
</programlisting>
</example>
</sect1>
@@ -540,7 +548,7 @@ echo 'index.tpl compiled at 2002-02-20 20:02';
<funcprototype>
<funcdef>string <function>smarty_outputfilter_<replaceable>name</replaceable></function></funcdef>
<paramdef>string <parameter>$template_output</parameter></paramdef>
<paramdef>object <parameter>&$smarty</parameter></paramdef>
<paramdef>object <parameter>&amp;$smarty</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
@@ -551,7 +559,9 @@ echo 'index.tpl compiled at 2002-02-20 20:02';
</para>
<example>
<title>output filter plugin</title>
<programlisting>
<programlisting role="php">
<![CDATA[
<?php
/*
* 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}))!',
'$1%40$2', $output);
}
?>
]]>
</programlisting>
</example>
</sect1>
@@ -589,24 +601,24 @@ echo 'index.tpl compiled at 2002-02-20 20:02';
<funcprototype>
<funcdef>bool <function>smarty_resource_<replaceable>name</replaceable>_source</function></funcdef>
<paramdef>string <parameter>$rsrc_name</parameter></paramdef>
<paramdef>string <parameter>&$source</parameter></paramdef>
<paramdef>object <parameter>&$smarty</parameter></paramdef>
<paramdef>string <parameter>&amp;$source</parameter></paramdef>
<paramdef>object <parameter>&amp;$smarty</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>bool <function>smarty_resource_<replaceable>name</replaceable>_timestamp</function></funcdef>
<paramdef>string <parameter>$rsrc_name</parameter></paramdef>
<paramdef>int <parameter>&$timestamp</parameter></paramdef>
<paramdef>object <parameter>&$smarty</parameter></paramdef>
<paramdef>int <parameter>&amp;$timestamp</parameter></paramdef>
<paramdef>object <parameter>&amp;$smarty</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>bool <function>smarty_resource_<replaceable>name</replaceable>_secure</function></funcdef>
<paramdef>string <parameter>$rsrc_name</parameter></paramdef>
<paramdef>object <parameter>&$smarty</parameter></paramdef>
<paramdef>object <parameter>&amp;$smarty</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>bool <function>smarty_resource_<replaceable>name</replaceable>_trusted</function></funcdef>
<paramdef>string <parameter>$rsrc_name</parameter></paramdef>
<paramdef>object <parameter>&$smarty</parameter></paramdef>
<paramdef>object <parameter>&amp;$smarty</parameter></paramdef>
</funcprototype>
</funcsynopsis>
@@ -716,7 +728,7 @@ function smarty_resource_db_trusted($tpl_name, &amp;$smarty)
<funcprototype>
<funcdef>string <function>smarty_insert_<replaceable>name</replaceable></function></funcdef>
<paramdef>array <parameter>$params</parameter></paramdef>
<paramdef>object <parameter>&$smarty</parameter></paramdef>
<paramdef>object <parameter>&amp;$smarty</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>