mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 02:44:27 +02:00
WS and properly using examples
This commit is contained in:
@@ -24,6 +24,7 @@ Topic: {$topic|truncate:40:"..."}
|
|||||||
|
|
||||||
{* apply modifier to a custom function *}
|
{* apply modifier to a custom function *}
|
||||||
{mailto|upper address="me@domain.dom"}
|
{mailto|upper address="me@domain.dom"}
|
||||||
|
r
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
@@ -52,8 +53,7 @@ Topic: {$topic|truncate:40:"..."}
|
|||||||
Smarty distribution). Second: with <link
|
Smarty distribution). Second: with <link
|
||||||
linkend="variable.security">$security</link> turned on all
|
linkend="variable.security">$security</link> turned on all
|
||||||
php-functions that are to be used as modifiers have to be
|
php-functions that are to be used as modifiers have to be
|
||||||
declared trusted in the <link
|
declared trusted in the <link linkend="variable.security.settings">
|
||||||
linkend="variable.security.settings">
|
|
||||||
$security_settings['MODIFIER_FUNCS']</link>-array.
|
$security_settings['MODIFIER_FUNCS']</link>-array.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@@ -197,20 +197,31 @@ Cold Wave Linked to Temperatures.
|
|||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>cat</title>
|
<title>cat</title>
|
||||||
<programlisting>
|
<programlisting role="php">
|
||||||
index.php:
|
<![CDATA[
|
||||||
|
<?php
|
||||||
$smarty = new Smarty;
|
$smarty = new Smarty;
|
||||||
$smarty->assign('articleTitle', "Psychics predict world didn't end");
|
$smarty->assign('articleTitle', "Psychics predict world didn't end");
|
||||||
$smarty->display('index.tpl');
|
$smarty->display('index.tpl');
|
||||||
|
?>
|
||||||
index.tpl:
|
]]>
|
||||||
|
</programlisting>
|
||||||
|
<para>
|
||||||
|
Where index.tpl is:
|
||||||
|
</para>
|
||||||
|
<programlisting>
|
||||||
|
<![CDATA[
|
||||||
{$articleTitle|cat:" yesterday."}
|
{$articleTitle|cat:" yesterday."}
|
||||||
|
]]>
|
||||||
OUTPUT:
|
</programlisting>
|
||||||
|
<para>
|
||||||
Psychics predict world didn't end yesterday.</programlisting>
|
This will output:
|
||||||
|
</para>
|
||||||
|
<screen>
|
||||||
|
<![CDATA[
|
||||||
|
Psychics predict world didn't end yesterday.
|
||||||
|
]]>
|
||||||
|
</screen>
|
||||||
</example>
|
</example>
|
||||||
</sect1>
|
</sect1>
|
||||||
<sect1 id="language.modifier.count.paragraphs">
|
<sect1 id="language.modifier.count.paragraphs">
|
||||||
@@ -220,25 +231,36 @@ Psychics predict world didn't end yesterday.</programlisting>
|
|||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>count_paragraphs</title>
|
<title>count_paragraphs</title>
|
||||||
<programlisting>
|
<programlisting role="php">
|
||||||
index.php:
|
<![CDATA[
|
||||||
|
<?php
|
||||||
$smarty = new Smarty;
|
$smarty = new Smarty;
|
||||||
$smarty->assign('articleTitle', "War Dims Hope for Peace. Child's Death Ruins
|
$smarty->assign('articleTitle', "War Dims Hope for Peace. Child's Death Ruins
|
||||||
Couple's Holiday.\n\nMan is Fatally Slain. Death Causes Loneliness, Feeling of Isolation.");
|
Couple's Holiday.\n\nMan is Fatally Slain. Death Causes Loneliness, Feeling of Isolation.");
|
||||||
$smarty->display('index.tpl');
|
$smarty->display('index.tpl');
|
||||||
|
?>
|
||||||
index.tpl:
|
]]>
|
||||||
|
</programlisting>
|
||||||
|
<para>
|
||||||
|
Where index.tpl is:
|
||||||
|
</para>
|
||||||
|
<programlisting>
|
||||||
|
<![CDATA[
|
||||||
{$articleTitle}
|
{$articleTitle}
|
||||||
{$articleTitle|count_paragraphs}
|
{$articleTitle|count_paragraphs}
|
||||||
|
]]>
|
||||||
OUTPUT:
|
</programlisting>
|
||||||
|
<para>
|
||||||
|
This will output:
|
||||||
|
</para>
|
||||||
|
<screen>
|
||||||
|
<![CDATA[
|
||||||
War Dims Hope for Peace. Child's Death Ruins Couple's Holiday.
|
War Dims Hope for Peace. Child's Death Ruins Couple's Holiday.
|
||||||
|
|
||||||
Man is Fatally Slain. Death Causes Loneliness, Feeling of Isolation.
|
Man is Fatally Slain. Death Causes Loneliness, Feeling of Isolation.
|
||||||
2</programlisting>
|
2
|
||||||
|
]]>
|
||||||
|
</screen>
|
||||||
</example>
|
</example>
|
||||||
</sect1>
|
</sect1>
|
||||||
<sect1 id="language.modifier.count.sentences">
|
<sect1 id="language.modifier.count.sentences">
|
||||||
@@ -248,22 +270,35 @@ Man is Fatally Slain. Death Causes Loneliness, Feeling of Isolation.
|
|||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>count_sentences</title>
|
<title>count_sentences</title>
|
||||||
<programlisting>
|
<programlisting role="php">
|
||||||
index.php:
|
<![CDATA[
|
||||||
|
<?php
|
||||||
|
|
||||||
$smarty = new Smarty;
|
$smarty = new Smarty;
|
||||||
$smarty->assign('articleTitle', 'Two Soviet Ships Collide - One Dies. Enraged Cow Injures Farmer with Axe.');
|
$smarty->assign('articleTitle', 'Two Soviet Ships Collide - One Dies. Enraged Cow Injures Farmer with Axe.');
|
||||||
$smarty->display('index.tpl');
|
$smarty->display('index.tpl');
|
||||||
|
|
||||||
index.tpl:
|
|
||||||
|
|
||||||
|
?>
|
||||||
|
]]>
|
||||||
|
</programlisting>
|
||||||
|
<para>
|
||||||
|
Where index.tpl is:
|
||||||
|
</para>
|
||||||
|
<programlisting>
|
||||||
|
<![CDATA[
|
||||||
{$articleTitle}
|
{$articleTitle}
|
||||||
{$articleTitle|count_sentences}
|
{$articleTitle|count_sentences}
|
||||||
|
]]>
|
||||||
OUTPUT:
|
</programlisting>
|
||||||
|
<para>
|
||||||
|
This will output:
|
||||||
|
</para>
|
||||||
|
<screen>
|
||||||
|
<![CDATA[
|
||||||
Two Soviet Ships Collide - One Dies. Enraged Cow Injures Farmer with Axe.
|
Two Soviet Ships Collide - One Dies. Enraged Cow Injures Farmer with Axe.
|
||||||
2</programlisting>
|
2
|
||||||
|
]]>
|
||||||
|
</screen>
|
||||||
</example>
|
</example>
|
||||||
</sect1>
|
</sect1>
|
||||||
<sect1 id="language.modifier.count.words">
|
<sect1 id="language.modifier.count.words">
|
||||||
@@ -273,24 +308,37 @@ Two Soviet Ships Collide - One Dies. Enraged Cow Injures Farmer with Axe.
|
|||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>count_words</title>
|
<title>count_words</title>
|
||||||
<programlisting>
|
<programlisting role="php">
|
||||||
index.php:
|
<![CDATA[
|
||||||
|
<?php
|
||||||
|
|
||||||
$smarty = new Smarty;
|
$smarty = new Smarty;
|
||||||
$smarty->assign('articleTitle', 'Dealers Will Hear Car Talk at Noon.');
|
$smarty->assign('articleTitle', 'Dealers Will Hear Car Talk at Noon.');
|
||||||
$smarty->display('index.tpl');
|
$smarty->display('index.tpl');
|
||||||
|
|
||||||
index.tpl:
|
|
||||||
|
|
||||||
|
?>
|
||||||
|
]]>
|
||||||
|
</programlisting>
|
||||||
|
<para>
|
||||||
|
Where index.tpl is:
|
||||||
|
</para>
|
||||||
|
<programlisting>
|
||||||
|
<![CDATA[
|
||||||
{$articleTitle}
|
{$articleTitle}
|
||||||
{$articleTitle|count_words}
|
{$articleTitle|count_words}
|
||||||
|
]]>
|
||||||
OUTPUT:
|
</programlisting>
|
||||||
|
<para>
|
||||||
|
This will output:
|
||||||
|
</para>
|
||||||
|
<screen>
|
||||||
|
<![CDATA[
|
||||||
Dealers Will Hear Car Talk at Noon.
|
Dealers Will Hear Car Talk at Noon.
|
||||||
7</programlisting>
|
7
|
||||||
|
]]>
|
||||||
|
</screen>
|
||||||
</example>
|
</example>
|
||||||
</sect1>
|
</sect1> <!-- didou -->
|
||||||
<sect1 id="language.modifier.date.format">
|
<sect1 id="language.modifier.date.format">
|
||||||
<title>date_format</title>
|
<title>date_format</title>
|
||||||
<informaltable frame="all">
|
<informaltable frame="all">
|
||||||
|
Reference in New Issue
Block a user