removed suggestions to use extract() from the manual

This commit is contained in:
messju
2004-01-14 16:16:24 +00:00
parent 96dd0fa51d
commit 04307bb560
2 changed files with 13 additions and 23 deletions

View File

@@ -230,12 +230,11 @@ function makeTimeStamp($year="",$month="",$day="")
<programlisting> <programlisting>
// be sure apache is configure for the .wml extensions! // be sure apache is configure for the .wml extensions!
// put this function somewhere in your application, or in Smarty.addons.php // put this function somewhere in your application, or in Smarty.addons.php
function insert_header() { function insert_header($params) {
// this function expects $content argument // this function expects $content argument
extract(func_get_arg(0)); if(empty($params['content']))
if(empty($content))
return; return;
header($content); header($params['content']);
return; return;
} }

View File

@@ -1221,9 +1221,10 @@ function do_translation ($params, $content, &amp;$smarty, &amp;$repeat) {
$smarty->register_function("date_now", "print_current_date"); $smarty->register_function("date_now", "print_current_date");
function print_current_date ($params) { function print_current_date ($params) {
extract($params); if(empty($params['format']))
if(empty($format)) $format = "%b %e, %Y";
$format="%b %e, %Y"; else
$format = $params['format'];
return strftime($format,time()); return strftime($format,time());
} }
@@ -2622,10 +2623,7 @@ require_once $smarty->_get_plugin_filepath('function', 'html_options');</program
<para> <para>
All attributes passed to template functions from the template are All attributes passed to template functions from the template are
contained in the <parameter>$params</parameter> as an associative contained in the <parameter>$params</parameter> as an associative
array. Either access those values directly, e.g. array.
<varname>$params['start']</varname> or use
<varname>extract($params)</varname> to import them into the symbol
table.
</para> </para>
<para> <para>
The output (return value) of the function will be substituted in place of the The output (return value) of the function will be substituted in place of the
@@ -2694,9 +2692,7 @@ Answer: {eightball}.</programlisting>
*/ */
function smarty_function_assign($params, &amp;$smarty) function smarty_function_assign($params, &amp;$smarty)
{ {
extract($params); if (empty($params['var'])) {
if (empty($var)) {
$smarty->trigger_error("assign: missing 'var' parameter"); $smarty->trigger_error("assign: missing 'var' parameter");
return; return;
} }
@@ -2706,7 +2702,7 @@ function smarty_function_assign($params, &amp;$smarty)
return; return;
} }
$smarty->assign($var, $value); $smarty->assign($params['var'], $params['value']);
} }
?&gt;</programlisting> ?&gt;</programlisting>
</example> </example>
@@ -2825,10 +2821,8 @@ function smarty_modifier_truncate($string, $length = 80, $etc = '...',
Only the opening tag of the block function may have attributes. All Only the opening tag of the block function may have attributes. All
attributes passed to template functions from the template are contained attributes passed to template functions from the template are contained
in the <parameter>$params</parameter> as an associative array. You can in the <parameter>$params</parameter> as an associative array. You can
either access those values directly, e.g. access those values as e.g. <varname>$params['start']</varname>.
<varname>$params['start']</varname> or use The opening tag attributes are also accessible to your function
<varname>extract($params)</varname> to import them into the symbol
table. The opening tag attributes are also accessible to your function
when processing the closing tag. when processing the closing tag.
</para> </para>
<para> <para>
@@ -3221,10 +3215,7 @@ function smarty_resource_db_trusted($tpl_name, &amp;$smarty)
</funcsynopsis> </funcsynopsis>
<para> <para>
The first parameter to the function is an associative array of The first parameter to the function is an associative array of
attributes passed to the insert. Either access those values directly, attributes passed to the insert.
e.g. <varname>$params['start']</varname> or use
<varname>extract($params)</varname> to import them into the symbol
table.
</para> </para>
<para> <para>
The insert function is supposed to return the result which will be The insert function is supposed to return the result which will be