This commit is contained in:
didou
2004-04-18 17:34:12 +00:00
parent a9bc3c91a0
commit 2e4e68462c
6 changed files with 121 additions and 116 deletions

View File

@@ -1,35 +1,35 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision$ -->
<sect1 id="language.escaping">
<title>Escaping Smarty Parsing</title>
<para>
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
a template. The problem arises as those languages use the { and } characters
which are also the default delimiters for Smarty.
</para>
<sect1 id="language.escaping">
<title>Escaping Smarty Parsing</title>
<para>
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
a template. The problem arises as those languages use the { and } characters
which are also the default delimiters for Smarty.
</para>
<para>
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.
</para>
<para>
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.
</para>
<para>
Including literal content is possible using <link
linkend="language.function.literal">{literal} .. {/literal}</link> blocks.
Similar to HTML entity usage, you can use <link
linkend="language.function.ldelim">{ldelim}</link> and <link
linkend="language.function.ldelim">{rdelim}</link> to display the current delimiters.
</para>
<para>
Including literal content is possible using <link
linkend="language.function.literal">{literal} .. {/literal}</link> blocks.
Similar to HTML entity usage, you can use <link
linkend="language.function.ldelim">{ldelim}</link> and <link
linkend="language.function.ldelim">{rdelim}</link> to display the current delimiters.
</para>
<para>
It is often convenient to simply change Smarty's <link
linkend="variable.left.delimiter">$left_delimiter</link> and
<link linkend="variable.right.delimiter">$right_delimiter</link>.
</para>
<example>
<title>changing delimiters example</title>
<programlisting role="php">
<para>
It is often convenient to simply change Smarty's <link
linkend="variable.left.delimiter">$left_delimiter</link> and
<link linkend="variable.right.delimiter">$right_delimiter</link>.
</para>
<example>
<title>changing delimiters example</title>
<programlisting role="php">
<![CDATA[
<?php
@@ -40,8 +40,13 @@ $smarty->assign('foo', 'bar');
$smarty->display('example.tpl');
?>
--- example.tpl
]]>
</programlisting>
<para>
Where example.tpl is:
</para>
<programlisting>
<![CDATA[
<script language="javascript">
var foo = <!--{$foo}-->;
function dosomething() {
@@ -50,8 +55,8 @@ function dosomething() {
dosomething();
</script>
]]>
</programlisting>
</example>
</programlisting>
</example>
</sect1>
<!-- Keep this comment at the end of the file
Local variables:
@@ -72,4 +77,4 @@ End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
-->

View File

@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision$ -->
<sect1 id="language.math">
<title>Math</title>
<para>
Math can be applied directly to variable values.
</para>
<example>
<title>math examples</title>
<programlisting>
<sect1 id="language.math">
<title>Math</title>
<para>
Math can be applied directly to variable values.
</para>
<example>
<title>math examples</title>
<programlisting>
<![CDATA[
{$foo+1}
@@ -23,8 +23,8 @@
{assign var="foo" value="`$foo+$bar`"}
]]>
</programlisting>
</example>
</programlisting>
</example>
</sect1>
<!-- Keep this comment at the end of the file
Local variables:
@@ -45,4 +45,4 @@ End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
-->

View File

@@ -1,24 +1,24 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision$ -->
<sect1 id="language.syntax.attributes">
<title>Attributes</title>
<para>
Most of the functions take attributes that specify or modify
their behavior. Attributes to Smarty functions are much like HTML
attributes. Static values don't have to be enclosed in quotes, but it
is recommended for literal strings. Variables may also be used, and
should not be in quotes.
</para>
<para>
Some attributes require boolean values (true or false). These can be
specified as either unquoted <literal>true</literal>,
<literal>on</literal>, and <literal>yes</literal>, or
<literal>false</literal>, <literal>off</literal>, and
<literal>no</literal>.
</para>
<example>
<title>function attribute syntax</title>
<programlisting>
<sect1 id="language.syntax.attributes">
<title>Attributes</title>
<para>
Most of the functions take attributes that specify or modify
their behavior. Attributes to Smarty functions are much like HTML
attributes. Static values don't have to be enclosed in quotes, but it
is recommended for literal strings. Variables may also be used, and
should not be in quotes.
</para>
<para>
Some attributes require boolean values (true or false). These can be
specified as either unquoted <literal>true</literal>,
<literal>on</literal>, and <literal>yes</literal>, or
<literal>false</literal>, <literal>off</literal>, and
<literal>no</literal>.
</para>
<example>
<title>function attribute syntax</title>
<programlisting>
<![CDATA[
{include file="header.tpl"}
@@ -32,8 +32,8 @@
{html_options values=$vals selected=$selected output=$output}
</select>
]]>
</programlisting>
</example>
</programlisting>
</example>
</sect1>
<!-- Keep this comment at the end of the file
Local variables:
@@ -54,4 +54,4 @@ End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
-->

View File

@@ -1,16 +1,16 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision$ -->
<sect1 id="language.syntax.comments">
<title>Comments</title>
<para>
Template comments are surrounded by asterisks, and that is surrounded
by the delimiter tags like so: {* this is a comment *}
Smarty comments are not displayed in the final output of the template.
They are used for making internal notes in the templates.
</para>
<example>
<title>Comments</title>
<programlisting>
<sect1 id="language.syntax.comments">
<title>Comments</title>
<para>
Template comments are surrounded by asterisks, and that is surrounded
by the delimiter tags like so: {* this is a comment *}
Smarty comments are not displayed in the final output of the template.
They are used for making internal notes in the templates.
</para>
<example>
<title>Comments</title>
<programlisting>
<![CDATA[
{* Smarty *}
@@ -26,8 +26,8 @@
{html_options values=$vals selected=$selected output=$output}
</select>
]]>
</programlisting>
</example>
</programlisting>
</example>
</sect1>
<!-- Keep this comment at the end of the file
Local variables:

View File

@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision$ -->
<sect1 id="language.syntax.functions">
<title>Functions</title>
<para>
Each Smarty tag either prints a
<link linkend="language.variables">variable</link> or invokes some sort
of function. Functions are processed and displayed by enclosing the
function and its attributes into delimiters like so: {funcname
attr1="val" attr2="val"}.
</para>
<example>
<title>function syntax</title>
<programlisting>
<sect1 id="language.syntax.functions">
<title>Functions</title>
<para>
Each Smarty tag either prints a
<link linkend="language.variables">variable</link> or invokes some sort
of function. Functions are processed and displayed by enclosing the
function and its attributes into delimiters like so: {funcname
attr1="val" attr2="val"}.
</para>
<example>
<title>function syntax</title>
<programlisting>
<![CDATA[
{config_load file="colors.conf"}
@@ -25,17 +25,17 @@
{include file="footer.tpl"}
]]>
</programlisting>
</example>
<para>
Both built-in functions and custom functions have the same syntax in
the templates. Built-in functions are the inner workings of Smarty,
such as <command>if</command>, <command>section</command> and
<command>strip</command>. They cannot be modified. Custom functions are
additional functions implemented via plugins. They can be modified to
your liking, or you can add new ones. <command>html_options</command> and
<command>html_select_date</command> are examples of custom functions.
</para>
</programlisting>
</example>
<para>
Both built-in functions and custom functions have the same syntax in
the templates. Built-in functions are the inner workings of Smarty,
such as <command>if</command>, <command>section</command> and
<command>strip</command>. They cannot be modified. Custom functions are
additional functions implemented via plugins. They can be modified to
your liking, or you can add new ones. <command>html_options</command> and
<command>html_select_date</command> are examples of custom functions.
</para>
</sect1>
<!-- Keep this comment at the end of the file
Local variables:
@@ -56,4 +56,4 @@ End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
-->

View File

@@ -1,16 +1,16 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision$ -->
<sect1 id="language.syntax.quotes">
<title>Embedding Vars in Double Quotes</title>
<para>
Smarty will recognize assigned variables embedded in double quotes so long
as the variables contain only numbers, letters, underscores and brackets
[]. With any other characters (period, object reference, etc.) the variable
must be surrounded by backticks.
</para>
<example>
<title>embedded quotes syntax</title>
<programlisting>
<sect1 id="language.syntax.quotes">
<title>Embedding Vars in Double Quotes</title>
<para>
Smarty will recognize assigned variables embedded in double quotes so long
as the variables contain only numbers, letters, underscores and brackets
[]. With any other characters (period, object reference, etc.) the variable
must be surrounded by backticks.
</para>
<example>
<title>embedded quotes syntax</title>
<programlisting>
<![CDATA[
SYNTAX EXAMPLES:
{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
{cycle values="one,two,`$smarty.config.myval`"} <-- must have backticks
]]>
</programlisting>
</example>
</programlisting>
</example>
</sect1>
<!-- Keep this comment at the end of the file
Local variables:
@@ -46,4 +46,4 @@ End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
-->