mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
added "eval" plugin docs
This commit is contained in:
1
NEWS
1
NEWS
@@ -1,5 +1,6 @@
|
|||||||
Version 2.0
|
Version 2.0
|
||||||
-----------
|
-----------
|
||||||
|
- added "eval" plugin for evaluating variables as templates (Monte)
|
||||||
- removed $tpl_file_ext class variable, no longer used. (Monte)
|
- removed $tpl_file_ext class variable, no longer used. (Monte)
|
||||||
- added "hex" and "hexentity" escape types to escape modifier. (Monte)
|
- added "hex" and "hexentity" escape types to escape modifier. (Monte)
|
||||||
- removed dependency on PEAR. (Andrei)
|
- removed dependency on PEAR. (Andrei)
|
||||||
|
@@ -2723,6 +2723,79 @@ OUTPUT:
|
|||||||
4<br>
|
4<br>
|
||||||
6<br>
|
6<br>
|
||||||
8<br></programlisting>
|
8<br></programlisting>
|
||||||
|
</example>
|
||||||
|
</sect3>
|
||||||
|
<sect3 id="language.function.eval">
|
||||||
|
<title>eval</title>
|
||||||
|
<informaltable frame=all>
|
||||||
|
<tgroup cols=5>
|
||||||
|
<colspec colname=param align=center>
|
||||||
|
<colspec colname=type align=center>
|
||||||
|
<colspec colname=required align=center>
|
||||||
|
<colspec colname=default align=center>
|
||||||
|
<colspec colname=desc>
|
||||||
|
<thead>
|
||||||
|
<row>
|
||||||
|
<entry>Attribute Name</entry>
|
||||||
|
<entry>Type</entry>
|
||||||
|
<entry>Required</entry>
|
||||||
|
<entry>Default</entry>
|
||||||
|
<entry>Description</entry>
|
||||||
|
</row>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<row>
|
||||||
|
<entry>var</entry>
|
||||||
|
<entry>mixed</entry>
|
||||||
|
<entry>Yes</entry>
|
||||||
|
<entry><emphasis>n/a</emphasis></entry>
|
||||||
|
<entry>variable (or string) to evaluate</entry>
|
||||||
|
</row>
|
||||||
|
</tbody>
|
||||||
|
</tgroup>
|
||||||
|
</informaltable>
|
||||||
|
<para>
|
||||||
|
eval is used to evaluate a variable as a template. This can be used
|
||||||
|
for things like embedding template tags/variables into variables or
|
||||||
|
tags/variables into config file variables.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
If you supply the special "assign" attribute, the output of the
|
||||||
|
eval function will be assigned to this template variable instead of
|
||||||
|
being output to the template.
|
||||||
|
</para>
|
||||||
|
<example>
|
||||||
|
<title>eval</title>
|
||||||
|
<programlisting>
|
||||||
|
setup.conf
|
||||||
|
----------
|
||||||
|
|
||||||
|
emphstart = <b>
|
||||||
|
emphend = </b>
|
||||||
|
title = Welcome to {$company}'s home page!
|
||||||
|
ErrorCity = You must supply a {#emphstart#}city{#emphend#}.
|
||||||
|
ErrorState = You must supply a {#emphstart#}state{#emphend#}.
|
||||||
|
|
||||||
|
|
||||||
|
index.tpl
|
||||||
|
---------
|
||||||
|
|
||||||
|
{config_load file="setup.conf"}
|
||||||
|
|
||||||
|
{eval var=$foo}
|
||||||
|
{eval var=#title#}
|
||||||
|
{eval var=#ErrorCity#}
|
||||||
|
{eval var=#ErrorState# assign="state_error"}
|
||||||
|
{$state_error}
|
||||||
|
|
||||||
|
OUTPUT:
|
||||||
|
|
||||||
|
This is the contents of foo.
|
||||||
|
Welcome to Foobar Pub & Grill's home page!
|
||||||
|
You must supply a <b>city</b>.
|
||||||
|
You must supply a <b>state</b>.
|
||||||
|
|
||||||
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
</sect3>
|
</sect3>
|
||||||
<sect3 id="language.function.fetch">
|
<sect3 id="language.function.fetch">
|
||||||
|
Reference in New Issue
Block a user