*** empty log message ***

This commit is contained in:
andrey
2002-02-26 22:31:18 +00:00
parent 629a7a5069
commit 279acbf01b
4 changed files with 230 additions and 167 deletions

View File

@@ -88,7 +88,7 @@ Parse error: parse error in /path/to/smarty/templates_c/index.tpl.php on line 75
If a variable is used frequently throughout your templates, applying If a variable is used frequently throughout your templates, applying
the default modifier every time it is mentioned can get a bit ugly. You the default modifier every time it is mentioned can get a bit ugly. You
can remedy this by assigning the variable its default value with the can remedy this by assigning the variable its default value with the
<link linkend="language.functions.assign">assign</link> function. <link linkend="language.function.assign">assign</link> function.
</para> </para>
<example> <example>
<title>Assigning a template variable its default value</title> <title>Assigning a template variable its default value</title>

View File

@@ -3,22 +3,27 @@
<chapter id="language"> <chapter id="language">
<title>Template Language</title> <title>Template Language</title>
<para> <para>
The templates are the heart of Smarty. These are the files that the designers The templates are the language of Smarty. These are the files that the designers
work with. They're basically pages made up of static content interspersed with work with. They're basically pages made up of static content interspersed with
template markup tags. These tags are placeholders for variables or blocks of logic. template markup tags. These tags are placeholders for variables or blocks of logic.
</para> </para>
<sect1 id="language.basic.syntax"> <sect1 id="language.basic.syntax">
<title>Basic Syntax</title> <title>Basic Syntax</title>
<para>
All Smarty template tags are enclosed within delimiters. By
default, these delimiters are <literal>{</literal> and
<literal>}</literal>, but they can be changed.
</para>
<para> <para>
For these examples, we will assume that you are using the default For these examples, we will assume that you are using the default
template tag delimiters, which are "{" and "}". In Smarty, all content delimiters. In Smarty, all content outside of delimiters is displayed as
outside of delimiter tags is displayed as static content, or unchanged. static content, or unchanged. When Smarty encounters template tags, it
When Smarty encounters template tags {}, it attempts to interpret what is attempts to interpret them, and displays the appropriate output in their
between the tags, and displays the appropriate output in place of them. place.
</para> </para>
<sect2 id="language.basic.syntax.comments"> <sect2 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
@@ -44,34 +49,15 @@
&lt;/SELECT&gt;</programlisting> &lt;/SELECT&gt;</programlisting>
</example> </example>
</sect2> </sect2>
<sect2>
<title>Attributes</title> <sect2 id="language.syntax.functions">
<title>Functions</title>
<para> <para>
Attributes to functions are much like HTML attributes. Static Each Smarty tag either prints a
values don't have to be enclosed in quotes, but it is recommended <link linkend="language.variables">variable</link> or invokes some sort
for literal strings. If not quoted, you may use a syntax that Smarty may confuse of function. Functions are processed and displayed by enclosing the
with another function, such as a boolean value. Variables may function and its attributes into delimiters like so: {funcname
also be used, and should not be in quotes. attr1="val" attr2="val"}.
</para>
<example>
<title>function attribute syntax</title>
<programlisting>
{include file="header.tpl"}
{include file=$includeFile}
{include file=#includeFile#}
&lt;SELECT name=company&gt;
{html_options values=$vals selected=$selected output=$output}
&lt;/SELECT&gt;</programlisting>
</example>
</sect2>
<sect2>
<title>blah</title>
<para>
Functions are processed and displayed by enclosing the function and its
attributes into delimiters like so: {funcname attr1="val" attr2="val"}
</para> </para>
<example> <example>
<title>function syntax</title> <title>function syntax</title>
@@ -89,20 +75,49 @@
{include file="footer.tpl"}</programlisting> {include file="footer.tpl"}</programlisting>
</example> </example>
<para> <para>
Both built-in functions and custom functions have the same syntax Both built-in functions and custom functions have the same syntax in
in the templates. Built-in functions are the inner workings of the templates. Built-in functions are the inner workings of Smarty,
Smarty, such as {if}, {section} and {strip}. They cannot be such as <command>if</command>, <command>section</command> and
modified. Custom functions are located in the Smarty.addons.class <command>strip</command>. They cannot be modified. Custom functions are
file. They can be modified to your liking, or add new ones. additional functions implemented via plugins. They can be modified to
{html_options} and {html_select_date} are examples of custom your liking, or you can add new ones. <command>html_options</command> and
functions. <command>html_select_date</command> are examples of custom functions.
</para>
<para>
Custom functions in Smarty work much the same as the built-in functions,
except that built-in functions cannot be modified. Custom functions are
located in Smarty.addons.php, built-in functions are not.
</para> </para>
</sect2> </sect2>
<sect2 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>
{include file="header.tpl"}
{include file=$includeFile}
{include file=#includeFile#}
{html_select_date display_days=yes}
&lt;SELECT name=company&gt;
{html_options values=$vals selected=$selected output=$output}
&lt;/SELECT&gt;</programlisting>
</example>
</sect2>
</sect1> </sect1>
<sect1 id="language.variables"> <sect1 id="language.variables">
@@ -1194,14 +1209,14 @@ s m o k e r s a r e p. . .</programlisting>
</sect2> </sect2>
</sect1> </sect1>
<sect1 id="language.commands"> <sect1 id="language.builtin.functions">
<title>Built-in Functions</title> <title>Built-in Functions</title>
<para> <para>
Smarty comes with several built-in functions. Built-in functions Smarty comes with several built-in functions. Built-in functions
are integral to the template language. You cannot create custom are integral to the template language. You cannot create custom
functions with the same names, nor can you modify built-in functions. functions with the same names, nor can you modify built-in functions.
</para> </para>
<sect2 id="builtin.functions.capture"> <sect2 id="language.function.capture">
<title>capture</title> <title>capture</title>
<para> <para>
capture is used to collect the output of the template into a capture is used to collect the output of the template into a
@@ -1246,7 +1261,7 @@ s m o k e r s a r e p. . .</programlisting>
</example> </example>
</para> </para>
</sect2> </sect2>
<sect2 id="builtin.functions.configload"> <sect2 id="language.function.config.load">
<title>config_load</title> <title>config_load</title>
<informaltable frame=all> <informaltable frame=all>
<tgroup cols=5> <tgroup cols=5>
@@ -1364,7 +1379,7 @@ s m o k e r s a r e p. . .</programlisting>
&lt;/html&gt;</programlisting> &lt;/html&gt;</programlisting>
</example> </example>
</sect2> </sect2>
<sect2 id="builtin.functions.include"> <sect2 id="language.function.include">
<title>include</title> <title>include</title>
<informaltable frame=all> <informaltable frame=all>
<tgroup cols=5> <tgroup cols=5>
@@ -1466,7 +1481,7 @@ s m o k e r s a r e p. . .</programlisting>
{include file="db:header.tpl"}</programlisting> {include file="db:header.tpl"}</programlisting>
</example> </example>
</sect2> </sect2>
<sect2 id="builtin.functions.include.php"> <sect2 id="language.function.include.php">
<title>include_php</title> <title>include_php</title>
<informaltable frame=all> <informaltable frame=all>
<tgroup cols=5> <tgroup cols=5>
@@ -1557,7 +1572,7 @@ index.tpl
{/foreach}</programlisting> {/foreach}</programlisting>
</example> </example>
</sect2> </sect2>
<sect2 id="builtin.functions.insert"> <sect2 id="language.function.insert">
<title>insert</title> <title>insert</title>
<informaltable frame=all> <informaltable frame=all>
<tgroup cols=5> <tgroup cols=5>
@@ -1673,7 +1688,7 @@ index.tpl
weather, search results, user feedback areas, etc. weather, search results, user feedback areas, etc.
</para> </para>
</sect2> </sect2>
<sect2> <sect2 id="language.function.if">
<title>if,elseif,else</title> <title>if,elseif,else</title>
<para> <para>
if statements in Smarty have much the same flexibility as php if if statements in Smarty have much the same flexibility as php if
@@ -1753,7 +1768,7 @@ index.tpl
{/if}</programlisting> {/if}</programlisting>
</example> </example>
</sect2> </sect2>
<sect2> <sect2 id="language.function.ldelim">
<title>ldelim,rdelim</title> <title>ldelim,rdelim</title>
<para> <para>
ldelim and rdelim are used for displaying the literal delimiter, in ldelim and rdelim are used for displaying the literal delimiter, in
@@ -1773,7 +1788,7 @@ OUTPUT:
{funcname} is how functions look in Smarty!</programlisting> {funcname} is how functions look in Smarty!</programlisting>
</example> </example>
</sect2> </sect2>
<sect2 id="builtin.functions.literal"> <sect2 id="language.function.literal">
<title>literal</title> <title>literal</title>
<para> <para>
Literal tags allow a block of data to be taken literally, Literal tags allow a block of data to be taken literally,
@@ -1805,7 +1820,7 @@ OUTPUT:
{/literal}</programlisting> {/literal}</programlisting>
</example> </example>
</sect2> </sect2>
<sect2 id="builtin.functions.php"> <sect2 id="language.function.php">
<title>php</title> <title>php</title>
<para> <para>
php tags allow php to be embedded directly into the template. They php tags allow php to be embedded directly into the template. They
@@ -1824,7 +1839,7 @@ OUTPUT:
{/php}</programlisting> {/php}</programlisting>
</example> </example>
</sect2> </sect2>
<sect2 id="builtin.functions.section"> <sect2 id="language.function.section">
<title>section,sectionelse</title> <title>section,sectionelse</title>
<informaltable frame=all> <informaltable frame=all>
<tgroup cols=5> <tgroup cols=5>
@@ -2370,7 +2385,7 @@ e-mail: jane@mydomain.com&lt;p&gt;</programlisting>
</example> </example>
</sect3> </sect3>
</sect2> </sect2>
<sect2 id="builtin.functions.foreach"> <sect2 id="language.function.foreach">
<title>foreach,foreachelse</title> <title>foreach,foreachelse</title>
<informaltable frame=all> <informaltable frame=all>
<tgroup cols=5> <tgroup cols=5>
@@ -2484,7 +2499,7 @@ fax: 555-3333&lt;br&gt;
cell: 760-1234&lt;br&gt;</programlisting> cell: 760-1234&lt;br&gt;</programlisting>
</example> </example>
</sect2> </sect2>
<sect2> <sect2 id="language.function.strip">
<title>strip</title> <title>strip</title>
<para> <para>
Many times web designers Many times web designers
@@ -2531,16 +2546,16 @@ OUTPUT:
</sect2> </sect2>
</sect1> </sect1>
<sect1 id="language.additional.functions"> <sect1 id="language.more.functions">
<title>Additional Functions</title> <title>Custom Functions</title>
<para> <para>
Smarty comes with several additional functions that you can Smarty comes with several additional functions that you can
use in the templates. use in the templates.
</para> </para>
<sect2 id="language.available.functions"> <sect2 id="language.custom.functions">
<title>Available Functions</title> <title>Additional Functions</title>
<sect3 id="language.functions.assign"> <sect3 id="language.function.assign">
<title>assign</title> <title>assign</title>
<informaltable frame=all> <informaltable frame=all>
<tgroup cols=5> <tgroup cols=5>
@@ -2595,7 +2610,7 @@ OUTPUT:
The value of $name is Bob.</programlisting> The value of $name is Bob.</programlisting>
</example> </example>
</sect3> </sect3>
<sect3> <sect3 id="language.function.counter">
<title>counter</title> <title>counter</title>
<informaltable frame=all> <informaltable frame=all>
<tgroup cols=5> <tgroup cols=5>
@@ -2692,7 +2707,7 @@ OUTPUT:
8&lt;br&gt;</programlisting> 8&lt;br&gt;</programlisting>
</example> </example>
</sect3> </sect3>
<sect3> <sect3 id="language.function.fetch">
<title>fetch</title> <title>fetch</title>
<informaltable frame=all> <informaltable frame=all>
<tgroup cols=5> <tgroup cols=5>
@@ -2771,7 +2786,7 @@ OUTPUT:
{/if}</programlisting> {/if}</programlisting>
</example> </example>
</sect3> </sect3>
<sect3 id="language.functions.html.options"> <sect3 id="language.function.html.options">
<title>html_options</title> <title>html_options</title>
<informaltable frame=all> <informaltable frame=all>
<tgroup cols=5> <tgroup cols=5>
@@ -2861,7 +2876,7 @@ OUTPUT:
&lt;/select&gt;</programlisting> &lt;/select&gt;</programlisting>
</example> </example>
</sect3> </sect3>
<sect3 id="language.functions.html.select.date"> <sect3 id="language.function.html.select.date">
<title>html_select_date</title> <title>html_select_date</title>
<informaltable frame=all> <informaltable frame=all>
<tgroup cols=5> <tgroup cols=5>
@@ -3141,7 +3156,7 @@ OUTPUT:
&lt;/select&gt;</programlisting> &lt;/select&gt;</programlisting>
</example> </example>
</sect3> </sect3>
<sect3 id="language.functions.html.select.time"> <sect3 id="language.function.html.select.time">
<title>html_select_time</title> <title>html_select_time</title>
<informaltable frame=all> <informaltable frame=all>
<tgroup cols=5> <tgroup cols=5>
@@ -3402,7 +3417,7 @@ OUTPUT:
&lt;/select&gt;</programlisting> &lt;/select&gt;</programlisting>
</example> </example>
</sect3> </sect3>
<sect3 id="language.functions.math"> <sect3 id="language.function.math">
<title>math</title> <title>math</title>
<informaltable frame=all> <informaltable frame=all>
<tgroup cols=5> <tgroup cols=5>
@@ -3516,14 +3531,14 @@ OUTPUT:
9.44</programlisting> 9.44</programlisting>
</example> </example>
</sect3> </sect3>
<sect3 id="language.functions.popup.init"> <sect3 id="language.function.popup.init">
<title>popup_init</title> <title>popup_init</title>
<para> <para>
popup is an integration of overLib, a library used for popup popup is an integration of overLib, a library used for popup
windows. These are used for context sensitive information, such as windows. These are used for context sensitive information, such as
help windows or tooltips. popup_init must be called once at the help windows or tooltips. popup_init must be called once at the
top of any page you plan on using the <link top of any page you plan on using the <link
linkend="language.functions.popup">popup</link> function. overLib linkend="language.function.popup">popup</link> function. overLib
was written by Erik Bosrup, and the homepage is located at was written by Erik Bosrup, and the homepage is located at
http://www.bosrup.com/web/overlib/. http://www.bosrup.com/web/overlib/.
</para> </para>
@@ -3531,7 +3546,7 @@ OUTPUT:
This was added to Smarty 1.4.4. This was added to Smarty 1.4.4.
</para> </para>
</sect3> </sect3>
<sect3 id="language.functions.popup"> <sect3 id="language.function.popup">
<title>popup</title> <title>popup</title>
<informaltable frame=all> <informaltable frame=all>
<tgroup cols=5> <tgroup cols=5>

View File

@@ -1,5 +1,6 @@
<part id="getting.started"> <part id="getting.started">
<title>Getting Started</title> <title>Getting Started</title>
<chapter id="overview"> <chapter id="overview">
<title>Overview</title> <title>Overview</title>
<sect1 id="what.is.smarty"> <sect1 id="what.is.smarty">
@@ -105,7 +106,7 @@
</para> </para>
</sect1> </sect1>
<sect1 id="installation.smarty"> <sect1 id="installing.smarty">
<title>Installing Smarty</title> <title>Installing Smarty</title>
<para> <para>
Installing Smarty is fairly straightforward, there are a few things to Installing Smarty is fairly straightforward, there are a few things to
@@ -172,6 +173,7 @@ chmod 700 cache</screen>
Next, try running the index.php script from your web browser. Next, try running the index.php script from your web browser.
</para> </para>
</sect1> </sect1>
<sect1 id="smarty.constants"> <sect1 id="smarty.constants">
<title>Constants</title> <title>Constants</title>
<para></para> <para></para>

View File

@@ -181,6 +181,52 @@
) )
(literal "()")))))))) (literal "()"))))))))
(element command
(let* ((command-name (data (current-node)))
(linkend
(string-append
"language.function."
(string-replace
(string-replace command-name "_" ".")
"::" ".")))
(target (element-with-id linkend))
(parent-gi (gi (parent))))
(cond
;; function names should be plain in FUNCDEF
((equal? parent-gi "funcdef")
(process-children))
;; if a valid ID for the target function is not found, or if the
;; FUNCTION tag is within the definition of the same function,
;; make it bold, add (), but don't make a link
((or (node-list-empty? target)
(equal? (case-fold-down
(data (node-list-first
(select-elements
(node-list-first
(children
(select-elements
(children
(ancestor-member (parent) (list "refentry")))
"refnamediv")))
"refname"))))
command-name))
($bold-seq$
(make sequence
(literal "{")
(process-children)
(literal "}"))))
;; else make a link to the function and add ()
(else
(make element gi: "A"
attributes: (list
(list "HREF" (href-to target)))
($bold-seq$
(make sequence
(literal "{")
(process-children)
(literal "}"))))))))
(element classname (element classname
(let* ((class-name (data (current-node))) (let* ((class-name (data (current-node)))