cvs: smarty / NEWS Smarty.class.php Smarty_Compiler.class.php
| From: | Andrei Zmievski | Date: | Wed, 03 Apr 2002 16:31:59 +0000 |
| Subject: | cvs: smarty / NEWS Smarty.class.php Smarty_Compiler.class.php | ||
| Groups: | php.smarty.cvs | ||
| Request: | Send a blank email to php-smarty-cvs+get-8@lists.php.net to get a copy of this message | ||
andrei Wed Apr 3 11:31:59 2002 EDT
Modified files:
/smarty NEWS Smarty.class.php Smarty_Compiler.class.php
Log:
- Added $smarty.template variable.
- Fixed {include_php} tag when dynamic values were used for 'file' attribute.
Index: smarty/NEWS
diff -u smarty/NEWS:1.181 smarty/NEWS:1.182
--- smarty/NEWS:1.181 Thu Mar 28 09:53:17 2002
+++ smarty/NEWS Wed Apr 3 11:31:58 2002
@@ -1,3 +1,6 @@
+ - fixed a problem with using dynamic values for 'file'
+ attribute of {include_php} tag. (Andrei)
+ - added $smarty.template variable. (Andrei)
- fixed several plugins that would not work if the plugin
directory was not the default one. (Andrei)
- implemented support for block functions. (Andrei)
@@ -339,4 +342,4 @@
------------
- initial release
-/* vim: set et tw=64: */
+/* vim: set et tw=64 ft=changelog: */
Index: smarty/Smarty.class.php
diff -u smarty/Smarty.class.php:1.258 smarty/Smarty.class.php:1.259
--- smarty/Smarty.class.php:1.258 Thu Mar 28 14:53:27 2002
+++ smarty/Smarty.class.php Wed Apr 3 11:31:59 2002
@@ -1009,6 +1009,33 @@
}
/*======================================================================*\
+ Function: _smarty_include_php()
+ Purpose: called for included templates
+\*======================================================================*/
+ function _smarty_include_php($_smarty_include_php_file, $_smarty_assign)
+ {
+ $this->_get_php_resource($_smarty_include_php_file, $_smarty_resource_type,
+ $_smarty_php_resource);
+
+ if (!empty($_smarty_assign)) {
+ ob_start();
+ if ($_smarty_resource_type == 'file') {
+ include_once($_smarty_php_resource);
+ } else {
+ eval($_smarty_php_resource);
+ }
+ $this->assign($_smarty_assign, ob_get_contents());
+ ob_end_clean();
+ } else {
+ if ($_smarty_resource_type == 'file') {
+ include_once($_smarty_php_resource);
+ } else {
+ eval($_smarty_php_resource);
+ }
+ }
+ }
+
+/*======================================================================*\
Function: _config_load
Purpose: load configuration values
\*======================================================================*/
Index: smarty/Smarty_Compiler.class.php
diff -u smarty/Smarty_Compiler.class.php:1.105 smarty/Smarty_Compiler.class.php:1.106
--- smarty/Smarty_Compiler.class.php:1.105 Tue Mar 26 16:01:52 2002
+++ smarty/Smarty_Compiler.class.php Wed Apr 3 11:31:59 2002
@@ -632,27 +632,10 @@
if (empty($attrs['file'])) {
$this->_syntax_error("missing 'file' attribute in include_php
tag");
}
-
- $this->_get_php_resource($this->_dequote($attrs['file']),
- $resource_type, $php_resource);
-
- if (!empty($attrs['assign'])) {
- $output = "<?php ob_start();\n";
- if ($resource_type == 'file') {
- $output .= 'include("' . $php_resource .
'");'."\n";
- } else {
- $output .= $php_resource;
- }
- $output .= "\$this->assign(" . $attrs['assign'] . ",
ob_get_contents()); ob_end_clean();\n?>";
- } else {
- if ($resource_type == 'file') {
- $output = '<?php include("' . $php_resource . '");
?>';
- } else {
- $output = '<?php ' . $php_resource . ' ?>';
- }
- }
- return $output;
+ $assign_var = $this->_dequote($attrs['assign']);
+
+ return "<?php \$this->_smarty_include_php($attrs[file], '$assign_var');
?>";
}
@@ -1349,6 +1332,13 @@
case 'capture':
return null;
+
+ case 'template':
+ $compiled_ref = "'$this->_current_file'";
+ if (count($indexes) > 1) {
+ $this->_syntax_error('$smarty' . implode('', $indexes)
.' is an invalid reference');
+ }
+ break;
default:
$this->_syntax_error('$smarty.' . $ref . ' is an unknown
reference');