--- nfo/php/libs/net.php.smarty/plugins/function.eval.php 2002/10/09 00:53:36 1.1
+++ nfo/php/libs/net.php.smarty/plugins/function.eval.php 2004/06/16 21:58:16 1.2
@@ -1,34 +1,45 @@
+ * Name: eval
+ * Purpose: evaluate a template variable as a template
+ * @link http://smarty.php.net/manual/en/language.function.eval.php {eval}
+ * (Smarty online manual)
+ * @param array
+ * @param Smarty
+ */
+function smarty_function_eval($params, &$smarty)
{
- extract($params);
- if (!isset($var)) {
- $this->trigger_error("eval: missing 'var' parameter");
+ if (!isset($params['var'])) {
+ $smarty->trigger_error("eval: missing 'var' parameter");
+ return;
+ }
+
+ if($params['var'] == '') {
return;
}
- if($var == '') {
- return;
- }
-
- $this->_compile_template("evaluated template", $var, $source);
-
- if (!empty($assign)) {
- ob_start();
- eval('?>' . $source);
- $this->assign($assign, ob_get_contents());
- ob_end_clean();
+
+ $smarty->_compile_source('evaluated template', $params['var'], $_var_compiled);
+
+ ob_start();
+ $smarty->_eval('?>' . $_var_compiled);
+ $_contents = ob_get_contents();
+ ob_end_clean();
+
+ if (!empty($params['assign'])) {
+ $smarty->assign($params['assign'], $_contents);
} else {
- eval('?>' . $source);
+ return $_contents;
}
}