diff --git a/NEWS b/NEWS
index 860ae74d..d034687a 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,4 @@
+ - added assign attribute to include and include_php, documented (Monte)
- added include_php built-in function. (Monte)
- added trusted_dir functionality, documented. (Monte)
- consolidated secure_dir tests to one function. (Monte)
diff --git a/Smarty_Compiler.class.php b/Smarty_Compiler.class.php
index 60cc7d9b..39e44264 100644
--- a/Smarty_Compiler.class.php
+++ b/Smarty_Compiler.class.php
@@ -431,18 +431,22 @@ class Smarty_Compiler extends Smarty {
$include_file = $arg_value;
continue;
}
+ elseif ($arg_name == 'assign') {
+ $assign_var = $arg_value;
+ continue;
+ }
if (is_bool($arg_value))
$arg_value = $arg_value ? 'true' : 'false';
$arg_list[] = "'$arg_name' => $arg_value";
}
- if (!empty($attrs['assign'])) {
+ if (isset($assign_var)) {
$return = "_tpl_vars;\n" .
"\$this->_smarty_include(".$include_file.", array(".implode(',', (array)$arg_list)."));\n" .
"\$this->_tpl_vars = \$_smarty_tpl_vars;\n" .
"unset(\$_smarty_tpl_vars);\n";
- $return .= "\$this->assign('".$this->_dequote($attrs['assign'])."',ob_get_contents()); ob_end_clean();\n?>";
+ $return .= "\$this->assign('".$this->_dequote($assign_var)."',ob_get_contents()); ob_end_clean();\n?>";
} else {
$return = "_tpl_vars;\n" .
diff --git a/docs.sgml b/docs.sgml
index 8048318c..52d2bcb1 100644
--- a/docs.sgml
+++ b/docs.sgml
@@ -2292,6 +2292,14 @@ pass=foobar
n/a
The name of the template file to include
+
+ assign
+ string
+ No
+ n/a
+ The name of the varible that the output of
+ include will be assigned to
+
[var ...]
[var type]
@@ -2308,6 +2316,11 @@ pass=foobar
available within the included template. The include tag must have
the attribute "file", which contains the template resource path.
+
+ You an optionally pass the assign attribute, which will specify a
+ template variable name that the output of include will be assigned
+ to instead of displayed. This was added to Smarty 1.5.0.
+
function include
@@ -2365,6 +2378,14 @@ pass=foobar
n/a
The name of the php file to include
+
+ assign
+ string
+ No
+ n/a
+ The name of the varible that the output of
+ include_php will be assigned to
+
@@ -2386,6 +2407,11 @@ pass=foobar
before hand.
+ You an optionally pass the assign attribute, which will specify a
+ template variable name that the output of include_php will be
+ assigned to instead of displayed.
+
+
include_php was added to Smarty 1.5.0.
diff --git a/libs/Smarty_Compiler.class.php b/libs/Smarty_Compiler.class.php
index 60cc7d9b..39e44264 100644
--- a/libs/Smarty_Compiler.class.php
+++ b/libs/Smarty_Compiler.class.php
@@ -431,18 +431,22 @@ class Smarty_Compiler extends Smarty {
$include_file = $arg_value;
continue;
}
+ elseif ($arg_name == 'assign') {
+ $assign_var = $arg_value;
+ continue;
+ }
if (is_bool($arg_value))
$arg_value = $arg_value ? 'true' : 'false';
$arg_list[] = "'$arg_name' => $arg_value";
}
- if (!empty($attrs['assign'])) {
+ if (isset($assign_var)) {
$return = "_tpl_vars;\n" .
"\$this->_smarty_include(".$include_file.", array(".implode(',', (array)$arg_list)."));\n" .
"\$this->_tpl_vars = \$_smarty_tpl_vars;\n" .
"unset(\$_smarty_tpl_vars);\n";
- $return .= "\$this->assign('".$this->_dequote($attrs['assign'])."',ob_get_contents()); ob_end_clean();\n?>";
+ $return .= "\$this->assign('".$this->_dequote($assign_var)."',ob_get_contents()); ob_end_clean();\n?>";
} else {
$return = "_tpl_vars;\n" .