Added $smarty.section.* syntax.

This commit is contained in:
andrey
2001-11-29 21:19:39 +00:00
parent 94c40ef787
commit c5bfaf1899
3 changed files with 11 additions and 2 deletions

1
NEWS
View File

@@ -1,3 +1,4 @@
- added $smarty.section.* syntax for accessing section properties. (Andrei)
- added custom cache handling function ability. (Monte) - added custom cache handling function ability. (Monte)
- added assign attribute to insert, fetch, math, and counter functions, - added assign attribute to insert, fetch, math, and counter functions,
documented. (Monte) documented. (Monte)

View File

@@ -1082,12 +1082,16 @@ class Smarty_Compiler extends Smarty {
break; break;
case 'foreach': case 'foreach':
case 'section':
if ($indexes[1]{0} != '.') { if ($indexes[1]{0} != '.') {
$this->_syntax_error('$smarty' . implode('', array_slice($indexes, 0, 2)) . ' is an invalid reference'); $this->_syntax_error('$smarty' . implode('', array_slice($indexes, 0, 2)) . ' is an invalid reference');
} }
$name = substr($indexes[1], 1); $name = substr($indexes[1], 1);
array_shift($indexes); array_shift($indexes);
$compiled_ref = "\$this->_foreach['$name']"; if ($ref == 'foreach')
$compiled_ref = "\$this->_foreach['$name']";
else
$compiled_ref = "\$this->_sections['$name']";
break; break;
/* These cases have to be handled at run-time. */ /* These cases have to be handled at run-time. */

View File

@@ -1082,12 +1082,16 @@ class Smarty_Compiler extends Smarty {
break; break;
case 'foreach': case 'foreach':
case 'section':
if ($indexes[1]{0} != '.') { if ($indexes[1]{0} != '.') {
$this->_syntax_error('$smarty' . implode('', array_slice($indexes, 0, 2)) . ' is an invalid reference'); $this->_syntax_error('$smarty' . implode('', array_slice($indexes, 0, 2)) . ' is an invalid reference');
} }
$name = substr($indexes[1], 1); $name = substr($indexes[1], 1);
array_shift($indexes); array_shift($indexes);
$compiled_ref = "\$this->_foreach['$name']"; if ($ref == 'foreach')
$compiled_ref = "\$this->_foreach['$name']";
else
$compiled_ref = "\$this->_sections['$name']";
break; break;
/* These cases have to be handled at run-time. */ /* These cases have to be handled at run-time. */