mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 02:44:27 +02:00
WS
This commit is contained in:
@@ -1,35 +1,35 @@
|
|||||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<sect1 id="language.escaping">
|
<sect1 id="language.escaping">
|
||||||
<title>Escaping Smarty Parsing</title>
|
<title>Escaping Smarty Parsing</title>
|
||||||
<para>
|
<para>
|
||||||
It is sometimes desirable or even necessary to have Smarty ignore sections it
|
It is sometimes desirable or even necessary to have Smarty ignore sections it
|
||||||
would otherwise parse. A classic example is embedding Javascript or CSS code in
|
would otherwise parse. A classic example is embedding Javascript or CSS code in
|
||||||
a template. The problem arises as those languages use the { and } characters
|
a template. The problem arises as those languages use the { and } characters
|
||||||
which are also the default delimiters for Smarty.
|
which are also the default delimiters for Smarty.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
The simplest thing is to avoid the situation altogether by separating your Javascript
|
The simplest thing is to avoid the situation altogether by separating your Javascript
|
||||||
and CSS code into their own files and then using standard HTML methods to access them.
|
and CSS code into their own files and then using standard HTML methods to access them.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
Including literal content is possible using <link
|
Including literal content is possible using <link
|
||||||
linkend="language.function.literal">{literal} .. {/literal}</link> blocks.
|
linkend="language.function.literal">{literal} .. {/literal}</link> blocks.
|
||||||
Similar to HTML entity usage, you can use <link
|
Similar to HTML entity usage, you can use <link
|
||||||
linkend="language.function.ldelim">{ldelim}</link> and <link
|
linkend="language.function.ldelim">{ldelim}</link> and <link
|
||||||
linkend="language.function.ldelim">{rdelim}</link> to display the current delimiters.
|
linkend="language.function.ldelim">{rdelim}</link> to display the current delimiters.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
It is often convenient to simply change Smarty's <link
|
It is often convenient to simply change Smarty's <link
|
||||||
linkend="variable.left.delimiter">$left_delimiter</link> and
|
linkend="variable.left.delimiter">$left_delimiter</link> and
|
||||||
<link linkend="variable.right.delimiter">$right_delimiter</link>.
|
<link linkend="variable.right.delimiter">$right_delimiter</link>.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>changing delimiters example</title>
|
<title>changing delimiters example</title>
|
||||||
<programlisting role="php">
|
<programlisting role="php">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
@@ -40,8 +40,13 @@ $smarty->assign('foo', 'bar');
|
|||||||
$smarty->display('example.tpl');
|
$smarty->display('example.tpl');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
]]>
|
||||||
--- example.tpl
|
</programlisting>
|
||||||
|
<para>
|
||||||
|
Where example.tpl is:
|
||||||
|
</para>
|
||||||
|
<programlisting>
|
||||||
|
<![CDATA[
|
||||||
<script language="javascript">
|
<script language="javascript">
|
||||||
var foo = <!--{$foo}-->;
|
var foo = <!--{$foo}-->;
|
||||||
function dosomething() {
|
function dosomething() {
|
||||||
@@ -50,8 +55,8 @@ function dosomething() {
|
|||||||
dosomething();
|
dosomething();
|
||||||
</script>
|
</script>
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
</sect1>
|
</sect1>
|
||||||
<!-- Keep this comment at the end of the file
|
<!-- Keep this comment at the end of the file
|
||||||
Local variables:
|
Local variables:
|
||||||
@@ -72,4 +77,4 @@ End:
|
|||||||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||||||
vim: et tw=78 syn=sgml
|
vim: et tw=78 syn=sgml
|
||||||
vi: ts=1 sw=1
|
vi: ts=1 sw=1
|
||||||
-->
|
-->
|
||||||
|
@@ -1,13 +1,13 @@
|
|||||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<sect1 id="language.math">
|
<sect1 id="language.math">
|
||||||
<title>Math</title>
|
<title>Math</title>
|
||||||
<para>
|
<para>
|
||||||
Math can be applied directly to variable values.
|
Math can be applied directly to variable values.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>math examples</title>
|
<title>math examples</title>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
{$foo+1}
|
{$foo+1}
|
||||||
|
|
||||||
@@ -23,8 +23,8 @@
|
|||||||
|
|
||||||
{assign var="foo" value="`$foo+$bar`"}
|
{assign var="foo" value="`$foo+$bar`"}
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
</sect1>
|
</sect1>
|
||||||
<!-- Keep this comment at the end of the file
|
<!-- Keep this comment at the end of the file
|
||||||
Local variables:
|
Local variables:
|
||||||
@@ -45,4 +45,4 @@ End:
|
|||||||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||||||
vim: et tw=78 syn=sgml
|
vim: et tw=78 syn=sgml
|
||||||
vi: ts=1 sw=1
|
vi: ts=1 sw=1
|
||||||
-->
|
-->
|
||||||
|
@@ -1,24 +1,24 @@
|
|||||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<sect1 id="language.syntax.attributes">
|
<sect1 id="language.syntax.attributes">
|
||||||
<title>Attributes</title>
|
<title>Attributes</title>
|
||||||
<para>
|
<para>
|
||||||
Most of the functions take attributes that specify or modify
|
Most of the functions take attributes that specify or modify
|
||||||
their behavior. Attributes to Smarty functions are much like HTML
|
their behavior. Attributes to Smarty functions are much like HTML
|
||||||
attributes. Static values don't have to be enclosed in quotes, but it
|
attributes. Static values don't have to be enclosed in quotes, but it
|
||||||
is recommended for literal strings. Variables may also be used, and
|
is recommended for literal strings. Variables may also be used, and
|
||||||
should not be in quotes.
|
should not be in quotes.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Some attributes require boolean values (true or false). These can be
|
Some attributes require boolean values (true or false). These can be
|
||||||
specified as either unquoted <literal>true</literal>,
|
specified as either unquoted <literal>true</literal>,
|
||||||
<literal>on</literal>, and <literal>yes</literal>, or
|
<literal>on</literal>, and <literal>yes</literal>, or
|
||||||
<literal>false</literal>, <literal>off</literal>, and
|
<literal>false</literal>, <literal>off</literal>, and
|
||||||
<literal>no</literal>.
|
<literal>no</literal>.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>function attribute syntax</title>
|
<title>function attribute syntax</title>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
{include file="header.tpl"}
|
{include file="header.tpl"}
|
||||||
|
|
||||||
@@ -32,8 +32,8 @@
|
|||||||
{html_options values=$vals selected=$selected output=$output}
|
{html_options values=$vals selected=$selected output=$output}
|
||||||
</select>
|
</select>
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
</sect1>
|
</sect1>
|
||||||
<!-- Keep this comment at the end of the file
|
<!-- Keep this comment at the end of the file
|
||||||
Local variables:
|
Local variables:
|
||||||
@@ -54,4 +54,4 @@ End:
|
|||||||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||||||
vim: et tw=78 syn=sgml
|
vim: et tw=78 syn=sgml
|
||||||
vi: ts=1 sw=1
|
vi: ts=1 sw=1
|
||||||
-->
|
-->
|
||||||
|
@@ -1,16 +1,16 @@
|
|||||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<sect1 id="language.syntax.comments">
|
<sect1 id="language.syntax.comments">
|
||||||
<title>Comments</title>
|
<title>Comments</title>
|
||||||
<para>
|
<para>
|
||||||
Template comments are surrounded by asterisks, and that is surrounded
|
Template comments are surrounded by asterisks, and that is surrounded
|
||||||
by the delimiter tags like so: {* this is a comment *}
|
by the delimiter tags like so: {* this is a comment *}
|
||||||
Smarty comments are not displayed in the final output of the template.
|
Smarty comments are not displayed in the final output of the template.
|
||||||
They are used for making internal notes in the templates.
|
They are used for making internal notes in the templates.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>Comments</title>
|
<title>Comments</title>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
{* Smarty *}
|
{* Smarty *}
|
||||||
|
|
||||||
@@ -26,8 +26,8 @@
|
|||||||
{html_options values=$vals selected=$selected output=$output}
|
{html_options values=$vals selected=$selected output=$output}
|
||||||
</select>
|
</select>
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
</sect1>
|
</sect1>
|
||||||
<!-- Keep this comment at the end of the file
|
<!-- Keep this comment at the end of the file
|
||||||
Local variables:
|
Local variables:
|
||||||
|
@@ -1,17 +1,17 @@
|
|||||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<sect1 id="language.syntax.functions">
|
<sect1 id="language.syntax.functions">
|
||||||
<title>Functions</title>
|
<title>Functions</title>
|
||||||
<para>
|
<para>
|
||||||
Each Smarty tag either prints a
|
Each Smarty tag either prints a
|
||||||
<link linkend="language.variables">variable</link> or invokes some sort
|
<link linkend="language.variables">variable</link> or invokes some sort
|
||||||
of function. Functions are processed and displayed by enclosing the
|
of function. Functions are processed and displayed by enclosing the
|
||||||
function and its attributes into delimiters like so: {funcname
|
function and its attributes into delimiters like so: {funcname
|
||||||
attr1="val" attr2="val"}.
|
attr1="val" attr2="val"}.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>function syntax</title>
|
<title>function syntax</title>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
{config_load file="colors.conf"}
|
{config_load file="colors.conf"}
|
||||||
|
|
||||||
@@ -25,17 +25,17 @@
|
|||||||
|
|
||||||
{include file="footer.tpl"}
|
{include file="footer.tpl"}
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
<para>
|
<para>
|
||||||
Both built-in functions and custom functions have the same syntax in
|
Both built-in functions and custom functions have the same syntax in
|
||||||
the templates. Built-in functions are the inner workings of Smarty,
|
the templates. Built-in functions are the inner workings of Smarty,
|
||||||
such as <command>if</command>, <command>section</command> and
|
such as <command>if</command>, <command>section</command> and
|
||||||
<command>strip</command>. They cannot be modified. Custom functions are
|
<command>strip</command>. They cannot be modified. Custom functions are
|
||||||
additional functions implemented via plugins. They can be modified to
|
additional functions implemented via plugins. They can be modified to
|
||||||
your liking, or you can add new ones. <command>html_options</command> and
|
your liking, or you can add new ones. <command>html_options</command> and
|
||||||
<command>html_select_date</command> are examples of custom functions.
|
<command>html_select_date</command> are examples of custom functions.
|
||||||
</para>
|
</para>
|
||||||
</sect1>
|
</sect1>
|
||||||
<!-- Keep this comment at the end of the file
|
<!-- Keep this comment at the end of the file
|
||||||
Local variables:
|
Local variables:
|
||||||
@@ -56,4 +56,4 @@ End:
|
|||||||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||||||
vim: et tw=78 syn=sgml
|
vim: et tw=78 syn=sgml
|
||||||
vi: ts=1 sw=1
|
vi: ts=1 sw=1
|
||||||
-->
|
-->
|
||||||
|
@@ -1,16 +1,16 @@
|
|||||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||||
<!-- $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>
|
||||||
<para>
|
<para>
|
||||||
Smarty will recognize assigned variables embedded in double quotes so long
|
Smarty will recognize assigned variables embedded in double quotes so long
|
||||||
as the variables contain only numbers, letters, underscores and brackets
|
as the variables contain only numbers, letters, underscores and brackets
|
||||||
[]. With any other characters (period, object reference, etc.) the variable
|
[]. With any other characters (period, object reference, etc.) the variable
|
||||||
must be surrounded by backticks.
|
must be surrounded by backticks.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>embedded quotes syntax</title>
|
<title>embedded quotes syntax</title>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
SYNTAX EXAMPLES:
|
SYNTAX EXAMPLES:
|
||||||
{func var="test $foo test"} <-- sees $foo
|
{func var="test $foo test"} <-- sees $foo
|
||||||
@@ -24,8 +24,8 @@ PRACTICAL EXAMPLES:
|
|||||||
{include file="subdir/$tpl_name.tpl"} <-- will replace $tpl_name with value
|
{include file="subdir/$tpl_name.tpl"} <-- will replace $tpl_name with value
|
||||||
{cycle values="one,two,`$smarty.config.myval`"} <-- must have backticks
|
{cycle values="one,two,`$smarty.config.myval`"} <-- must have backticks
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
</sect1>
|
</sect1>
|
||||||
<!-- Keep this comment at the end of the file
|
<!-- Keep this comment at the end of the file
|
||||||
Local variables:
|
Local variables:
|
||||||
@@ -46,4 +46,4 @@ End:
|
|||||||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||||||
vim: et tw=78 syn=sgml
|
vim: et tw=78 syn=sgml
|
||||||
vi: ts=1 sw=1
|
vi: ts=1 sw=1
|
||||||
-->
|
-->
|
||||||
|
Reference in New Issue
Block a user