From c5bfaf1899e442f9f9f36e5b938cc96655ff80c2 Mon Sep 17 00:00:00 2001 From: andrey Date: Thu, 29 Nov 2001 21:19:39 +0000 Subject: [PATCH] Added $smarty.section.* syntax. --- NEWS | 1 + Smarty_Compiler.class.php | 6 +++++- libs/Smarty_Compiler.class.php | 6 +++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 6be425da..e9108869 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,4 @@ + - added $smarty.section.* syntax for accessing section properties. (Andrei) - added custom cache handling function ability. (Monte) - added assign attribute to insert, fetch, math, and counter functions, documented. (Monte) diff --git a/Smarty_Compiler.class.php b/Smarty_Compiler.class.php index d85a874c..8299f122 100644 --- a/Smarty_Compiler.class.php +++ b/Smarty_Compiler.class.php @@ -1082,12 +1082,16 @@ class Smarty_Compiler extends Smarty { break; case 'foreach': + case 'section': if ($indexes[1]{0} != '.') { $this->_syntax_error('$smarty' . implode('', array_slice($indexes, 0, 2)) . ' is an invalid reference'); } $name = substr($indexes[1], 1); array_shift($indexes); - $compiled_ref = "\$this->_foreach['$name']"; + if ($ref == 'foreach') + $compiled_ref = "\$this->_foreach['$name']"; + else + $compiled_ref = "\$this->_sections['$name']"; break; /* These cases have to be handled at run-time. */ diff --git a/libs/Smarty_Compiler.class.php b/libs/Smarty_Compiler.class.php index d85a874c..8299f122 100644 --- a/libs/Smarty_Compiler.class.php +++ b/libs/Smarty_Compiler.class.php @@ -1082,12 +1082,16 @@ class Smarty_Compiler extends Smarty { break; case 'foreach': + case 'section': if ($indexes[1]{0} != '.') { $this->_syntax_error('$smarty' . implode('', array_slice($indexes, 0, 2)) . ' is an invalid reference'); } $name = substr($indexes[1], 1); array_shift($indexes); - $compiled_ref = "\$this->_foreach['$name']"; + if ($ref == 'foreach') + $compiled_ref = "\$this->_foreach['$name']"; + else + $compiled_ref = "\$this->_sections['$name']"; break; /* These cases have to be handled at run-time. */