added eval function to plugin dir

This commit is contained in:
mohrt
2002-02-27 22:30:05 +00:00
parent a15d547a85
commit e3556e0c0b
2 changed files with 68 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: function
* Name: eval
* Purpose: evaluate a template variable as a template
* -------------------------------------------------------------
*/
function smarty_function_eval($params, &$this)
{
extract($params);
if (empty($var)) {
$this->trigger_error("assign: missing 'var' parameter");
return;
}
$this->_compile_template("eval_var",$var,$source);
if (!empty($assign)) {
ob_start();
eval('?>'.$source);
$this->assign($assign,ob_get_contents());
ob_end_clean();
} else {
eval('?>'.$source);
}
}
/* vim: set expandtab: */
?>

34
plugins/function.eval.php Normal file
View File

@@ -0,0 +1,34 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: function
* Name: eval
* Purpose: evaluate a template variable as a template
* -------------------------------------------------------------
*/
function smarty_function_eval($params, &$this)
{
extract($params);
if (empty($var)) {
$this->trigger_error("assign: missing 'var' parameter");
return;
}
$this->_compile_template("eval_var",$var,$source);
if (!empty($assign)) {
ob_start();
eval('?>'.$source);
$this->assign($assign,ob_get_contents());
ob_end_clean();
} else {
eval('?>'.$source);
}
}
/* vim: set expandtab: */
?>