Files
smarty/libs/plugins/function.eval.php

40 lines
767 B
PHP
Raw Normal View History

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);
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
ob_start();
eval('?>' . $source);
$contents = ob_get_contents();
ob_end_clean();
2002-02-27 22:30:05 +00:00
if (!empty($assign)) {
$this->assign($assign, $contents);
2002-02-27 22:30:05 +00:00
} else {
return $contents;
2002-02-27 22:30:05 +00:00
}
}
/* vim: set expandtab: */
?>