2002-02-27 22:30:05 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Smarty plugin
|
|
|
|
* -------------------------------------------------------------
|
|
|
|
* Type: function
|
|
|
|
* Name: eval
|
|
|
|
* Purpose: evaluate a template variable as a template
|
|
|
|
* -------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
function smarty_function_eval($params, &$this)
|
|
|
|
{
|
|
|
|
extract($params);
|
|
|
|
|
2002-06-29 16:04:41 +00:00
|
|
|
if (!isset($var)) {
|
|
|
|
$this->trigger_error("eval: missing 'var' parameter");
|
2002-02-27 22:30:05 +00:00
|
|
|
return;
|
|
|
|
}
|
2002-06-29 16:07:02 +00:00
|
|
|
if($var == '') {
|
|
|
|
return;
|
|
|
|
}
|
2002-02-27 22:30:05 +00:00
|
|
|
|
2002-02-27 22:35:34 +00:00
|
|
|
$this->_compile_template("evaluated template", $var, $source);
|
2002-02-27 22:30:05 +00:00
|
|
|
|
2003-01-08 17:34:45 +00:00
|
|
|
ob_start();
|
|
|
|
eval('?>' . $source);
|
|
|
|
$contents = ob_get_contents();
|
|
|
|
ob_end_clean();
|
|
|
|
|
2002-02-27 22:30:05 +00:00
|
|
|
if (!empty($assign)) {
|
2003-01-08 17:34:45 +00:00
|
|
|
$this->assign($assign, $contents);
|
2002-02-27 22:30:05 +00:00
|
|
|
} else {
|
2003-01-08 17:34:45 +00:00
|
|
|
return $contents;
|
2002-02-27 22:30:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* vim: set expandtab: */
|
|
|
|
|
|
|
|
?>
|