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

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