mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 10:24:26 +02:00
added eval function to plugin dir
This commit is contained in:
34
libs/plugins/function.eval.php
Normal file
34
libs/plugins/function.eval.php
Normal 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
34
plugins/function.eval.php
Normal 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: */
|
||||||
|
|
||||||
|
?>
|
Reference in New Issue
Block a user