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