mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-06 19:34:27 +02:00
Minor formatting and error correction
This commit is contained in:
@@ -4,11 +4,11 @@
|
|||||||
<title>Basic Syntax</title>
|
<title>Basic Syntax</title>
|
||||||
<para>
|
<para>
|
||||||
All Smarty template tags are enclosed within delimiters. By
|
All Smarty template tags are enclosed within delimiters. By
|
||||||
default, these delimiters are <literal>{</literal> and
|
default these are <literal>{</literal> and
|
||||||
<literal>}</literal>, but they can be <link linkend="variable.left.delimiter">changed</link>.
|
<literal>}</literal>, but they can be <link linkend="variable.left.delimiter">changed</link>.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
For these examples, we will assume that you are using the default
|
For examples, we will assume that you are using the default
|
||||||
delimiters. In Smarty, all content outside of delimiters is displayed as
|
delimiters. In Smarty, all content outside of delimiters is displayed as
|
||||||
static content, or unchanged. When Smarty encounters template tags, it
|
static content, or unchanged. When Smarty encounters template tags, it
|
||||||
attempts to interpret them, and displays the appropriate output in their
|
attempts to interpret them, and displays the appropriate output in their
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
&designers.language-basic-syntax.language-syntax-quotes;
|
&designers.language-basic-syntax.language-syntax-quotes;
|
||||||
&designers.language-basic-syntax.language-math;
|
&designers.language-basic-syntax.language-math;
|
||||||
&designers.language-basic-syntax.language-escaping;
|
&designers.language-basic-syntax.language-escaping;
|
||||||
|
|
||||||
</chapter>
|
</chapter>
|
||||||
<!-- Keep this comment at the end of the file
|
<!-- Keep this comment at the end of the file
|
||||||
Local variables:
|
Local variables:
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
should not be in quotes.
|
should not be in quotes.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Some attributes require boolean values (true or false). These
|
Some attributes require boolean values (&true; or &false;). These
|
||||||
can be specified
|
can be specified
|
||||||
as either unquoted <literal>true</literal>,
|
as either unquoted <literal>true</literal>,
|
||||||
<literal>on</literal>, and <literal>yes</literal>, or
|
<literal>on</literal>, and <literal>yes</literal>, or
|
||||||
|
@@ -6,10 +6,19 @@
|
|||||||
Template comments are surrounded by asterisks, and that is surrounded
|
Template comments are surrounded by asterisks, and that is surrounded
|
||||||
by the
|
by the
|
||||||
<link linkend="variable.left.delimiter">delimiter</link>
|
<link linkend="variable.left.delimiter">delimiter</link>
|
||||||
tags like so: <literal>{* this is a comment *}</literal>
|
tags like so:
|
||||||
|
</para>
|
||||||
|
<informalexample>
|
||||||
|
<programlisting>
|
||||||
|
<![CDATA[
|
||||||
|
{* this is a comment *}
|
||||||
|
]]>
|
||||||
|
</programlisting>
|
||||||
|
</informalexample>
|
||||||
|
<para>
|
||||||
Smarty comments are NOT displayed in the final output of the template,
|
Smarty comments are NOT displayed in the final output of the template,
|
||||||
unlike <literal><!-- HTML comments --></literal>
|
unlike <literal><!-- HTML comments --></literal>.
|
||||||
these are useful for making internal notes in the templates which no one will see ;-)
|
These are useful for making internal notes in the templates which no one will see ;-)
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>Comments within a template</title>
|
<title>Comments within a template</title>
|
||||||
@@ -53,6 +62,18 @@ Multi line comment block with credits block
|
|||||||
</select>
|
</select>
|
||||||
*}
|
*}
|
||||||
|
|
||||||
|
<!-- Show header from affiliate is disabled -->
|
||||||
|
{* $affiliate|upper *}
|
||||||
|
|
||||||
|
{* you cannot nest comments *}
|
||||||
|
{*
|
||||||
|
<select name="company">
|
||||||
|
{* <option value="0">-- none -- </option> *}
|
||||||
|
{html_options options=$vals selected=$selected_id}
|
||||||
|
</select>
|
||||||
|
*}
|
||||||
|
|
||||||
|
|
||||||
{* cvs tag for a template, below the 36 SHOULD be an american currency
|
{* cvs tag for a template, below the 36 SHOULD be an american currency
|
||||||
. however its converted in cvs.. *}
|
. however its converted in cvs.. *}
|
||||||
{* $Id: Exp $ *}
|
{* $Id: Exp $ *}
|
||||||
|
@@ -2,24 +2,35 @@
|
|||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<sect1 id="language.syntax.quotes">
|
<sect1 id="language.syntax.quotes">
|
||||||
<title>Embedding Vars in Double Quotes</title>
|
<title>Embedding Vars in Double Quotes</title>
|
||||||
|
|
||||||
|
<itemizedlist>
|
||||||
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Smarty will recognize <link
|
Smarty will recognize <link
|
||||||
linkend="api.assign">assigned</link>
|
linkend="api.assign">assigned</link>
|
||||||
<link linkend="language.syntax.variables">variables</link>
|
<link linkend="language.syntax.variables">variables</link>
|
||||||
embedded in double quotes so long as the variable name contains only numbers,
|
embedded in "double quotes" so long as the variable name contains only numbers,
|
||||||
letters, underscores and brackets[]
|
letters, under_scores and brackets[].
|
||||||
(see <ulink url="&url.php-manual;language.variables">naming</ulink>).
|
See <ulink url="&url.php-manual;language.variables">naming</ulink>
|
||||||
With any other characters (period,
|
for more detail.
|
||||||
object reference, etc.) the variable must be surrounded by
|
</para></listitem>
|
||||||
`backticks`. You cannot embed
|
|
||||||
|
<listitem><para>
|
||||||
|
With any other characters, for example a .period or
|
||||||
|
<literal>$object>reference</literal>, then the variable must be
|
||||||
|
surrounded by <literal>`backticks`</literal>.
|
||||||
|
</para></listitem>
|
||||||
|
|
||||||
|
<listitem><para>You cannot embed
|
||||||
<link linkend="language.modifiers">modifiers</link>, they must always
|
<link linkend="language.modifiers">modifiers</link>, they must always
|
||||||
be applied outside of quotes.
|
be applied outside of quotes.
|
||||||
</para>
|
</para></listitem>
|
||||||
|
</itemizedlist>
|
||||||
|
|
||||||
<example>
|
<example>
|
||||||
<title>embedded quotes syntax</title>
|
<title>Syntax examples</title>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
SYNTAX EXAMPLES:
|
|
||||||
{func var="test $foo test"} <-- sees $foo
|
{func var="test $foo test"} <-- sees $foo
|
||||||
{func var="test $foo_bar test"} <-- sees $foo_bar
|
{func var="test $foo_bar test"} <-- sees $foo_bar
|
||||||
{func var="test $foo[0] test"} <-- sees $foo[0]
|
{func var="test $foo[0] test"} <-- sees $foo[0]
|
||||||
@@ -27,13 +38,32 @@ SYNTAX EXAMPLES:
|
|||||||
{func var="test $foo.bar test"} <-- sees $foo (not $foo.bar)
|
{func var="test $foo.bar test"} <-- sees $foo (not $foo.bar)
|
||||||
{func var="test `$foo.bar` test"} <-- sees $foo.bar
|
{func var="test `$foo.bar` test"} <-- sees $foo.bar
|
||||||
{func var="test `$foo.bar` test"|escape} <-- modifiers outside quotes!
|
{func var="test `$foo.bar` test"|escape} <-- modifiers outside quotes!
|
||||||
|
]]>
|
||||||
|
</programlisting>
|
||||||
|
</example>
|
||||||
|
|
||||||
PRACTICAL EXAMPLES:
|
<example>
|
||||||
{include file="subdir/$tpl_name.tpl"} <-- will replace $tpl_name with value
|
<title>Practical examples</title>
|
||||||
{cycle values="one,two,`$smarty.config.myval`"} <-- must have backticks
|
<programlisting>
|
||||||
|
<![CDATA[
|
||||||
|
{* will replace $tpl_name with value *}
|
||||||
|
{include file="subdir/$tpl_name.tpl"}
|
||||||
|
|
||||||
|
{* doesn't replace $tpl_name *}
|
||||||
|
{include file='subdir/$tpl_name.tpl'} <--
|
||||||
|
|
||||||
|
{* must have backticks as it contains a . *}
|
||||||
|
{cycle values="one,two,`$smarty.config.myval`"}
|
||||||
|
|
||||||
|
{* same as $module['contact'].'.tpl' in a php script
|
||||||
|
{include file="`$module.contact`.tpl"}
|
||||||
|
|
||||||
|
{* same as $module[$view].'.tpl' in a php script
|
||||||
|
{include file="$module.$view.tpl"}
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
See also <link linkend="language.modifier.escape"><varname>escape</varname></link>.
|
See also <link linkend="language.modifier.escape"><varname>escape</varname></link>.
|
||||||
</para>
|
</para>
|
||||||
|
@@ -7,12 +7,12 @@
|
|||||||
are the integral part of the smarty template engine. You cannot create your own
|
are the integral part of the smarty template engine. You cannot create your own
|
||||||
<link linkend="language.custom.functions">custom functions</link>
|
<link linkend="language.custom.functions">custom functions</link>
|
||||||
with the same name; and you should not need to
|
with the same name; and you should not need to
|
||||||
modify the built-in functions.
|
modify the built-in functions.</para>
|
||||||
</para>
|
|
||||||
<para>
|
<para>
|
||||||
A few on these functions have an <parameter>assign</parameter>
|
A few of these functions have an <parameter>assign</parameter>
|
||||||
attribute which collects the result the function to a named
|
attribute which collects the result the function to a named template
|
||||||
variable within a template instead of being output;
|
variable instead of being output;
|
||||||
much like the <link linkend="language.function.assign">
|
much like the <link linkend="language.function.assign">
|
||||||
<varname>{assign}</varname></link> function.
|
<varname>{assign}</varname></link> function.
|
||||||
</para>
|
</para>
|
||||||
|
@@ -3,11 +3,11 @@
|
|||||||
<sect1 id="language.modifier.escape">
|
<sect1 id="language.modifier.escape">
|
||||||
<title>escape</title>
|
<title>escape</title>
|
||||||
<para>
|
<para>
|
||||||
This is used to encode/escape a variable to <literal>html</literal>,
|
<varname>escape</varname> is used to encode or escape a variable to for example <literal>html</literal>,
|
||||||
<literal>url</literal>, <literal>single quotes</literal>,
|
<literal>url</literal>, <literal>single quotes</literal>,
|
||||||
<literal>hex</literal>, <literal>hexentity</literal>,
|
<literal>hex</literal>, <literal>hexentity</literal>,
|
||||||
<literal>javascript</literal> and <literal>mail</literal>.
|
<literal>javascript</literal> and <literal>mail</literal>.
|
||||||
By default its <literal>html</literal> escaped.
|
By default its <literal>html</literal>.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<informaltable frame="all">
|
<informaltable frame="all">
|
||||||
@@ -73,37 +73,36 @@ $smarty->assign('EmailAddress','smarty@example.com');
|
|||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
<para>
|
<para>
|
||||||
Where template is:
|
These are example <literal>escape</literal> template lines followed by the output
|
||||||
</para>
|
</para>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
{$articleTitle}
|
{$articleTitle}
|
||||||
|
'Stiff Opposition Expected to Casketless Funeral Plan'
|
||||||
|
|
||||||
{$articleTitle|escape}
|
{$articleTitle|escape}
|
||||||
|
'Stiff Opposition Expected to Casketless Funeral Plan'
|
||||||
|
|
||||||
{$articleTitle|escape:'html'} {* escapes & " ' < > *}
|
{$articleTitle|escape:'html'} {* escapes & " ' < > *}
|
||||||
|
'Stiff Opposition Expected to Casketless Funeral Plan'
|
||||||
|
|
||||||
{$articleTitle|escape:'htmlall'} {* escapes ALL html entities *}
|
{$articleTitle|escape:'htmlall'} {* escapes ALL html entities *}
|
||||||
{$articleTitle|escape:'url'}
|
'Stiff Opposition Expected to Casketless Funeral Plan'
|
||||||
|
|
||||||
|
<a href="?title={$articleTitle|escape:'url'}">click here</a>
|
||||||
|
<a href="?title=%27Stiff+Opposition+Expected+to+Casketless+Funeral+Plan%27">click here</a>
|
||||||
|
|
||||||
{$articleTitle|escape:'quotes'}
|
{$articleTitle|escape:'quotes'}
|
||||||
|
\'Stiff Opposition Expected to Casketless Funeral Plan\'
|
||||||
|
|
||||||
<a href="mailto:{$EmailAddress|escape:"hex"}">{$EmailAddress|escape:"hexentity"}</a>
|
<a href="mailto:{$EmailAddress|escape:"hex"}">{$EmailAddress|escape:"hexentity"}</a>
|
||||||
{$EmailAddress|escape:'mail'} {* this converts to email to text *}
|
{$EmailAddress|escape:'mail'} {* this converts to email to text *}
|
||||||
|
<a href="mailto:%62%6f%..snip..%65%74">bob..snip..et</a>
|
||||||
|
|
||||||
{'mail@example.com'|escape:'mail'}
|
{'mail@example.com'|escape:'mail'}
|
||||||
|
smarty [AT] example [DOT] com
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
<para>
|
|
||||||
Will output:
|
|
||||||
</para>
|
|
||||||
<screen>
|
|
||||||
<![CDATA[
|
|
||||||
'Stiff Opposition Expected to Casketless Funeral Plan'
|
|
||||||
'Stiff Opposition Expected to Casketless Funeral Plan'
|
|
||||||
'Stiff Opposition Expected to Casketless Funeral Plan'
|
|
||||||
'Stiff Opposition Expected to Casketless Funeral Plan'
|
|
||||||
%27Stiff+Opposition+Expected+to+Casketless+Funeral+Plan%27
|
|
||||||
\'Stiff Opposition Expected to Casketless Funeral Plan\'
|
|
||||||
<a href="mailto:%62%6f%..snip..%65%74">bob..snip..et</a>
|
|
||||||
smarty [AT] example [DOT] com
|
|
||||||
mail [AT] example [DOT] com
|
|
||||||
]]>
|
|
||||||
</screen>
|
|
||||||
</example>
|
</example>
|
||||||
|
|
||||||
<example>
|
<example>
|
||||||
|
Reference in New Issue
Block a user