Files
smarty/plugins/function.eval.php

35 lines
728 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 (empty($var)) {
$this->trigger_error("assign: missing 'var' parameter");
return;
}
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: */
?>