mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 02:44:27 +02:00
enabled numerical constants be parsed as statements.
(like {10} or {10|@range:12} )
This commit is contained in:
@@ -105,6 +105,8 @@ class Smarty_Compiler extends Smarty {
|
|||||||
// $foo[$bar]
|
// $foo[$bar]
|
||||||
// $foo[5][blah]
|
// $foo[5][blah]
|
||||||
// $foo[5].bar[$foobar][4]
|
// $foo[5].bar[$foobar][4]
|
||||||
|
$this->_num_const_regexp = '\-?\d+(?:\.\d+)?';
|
||||||
|
|
||||||
$this->_dvar_math_regexp = '[\+\-\*\/\%]';
|
$this->_dvar_math_regexp = '[\+\-\*\/\%]';
|
||||||
$this->_dvar_math_var_regexp = '[\$\w\.\+\-\*\/\%\d\>\[\]]';
|
$this->_dvar_math_var_regexp = '[\$\w\.\+\-\*\/\%\d\>\[\]]';
|
||||||
$this->_dvar_guts_regexp = '\w+(?:' . $this->_var_bracket_regexp
|
$this->_dvar_guts_regexp = '\w+(?:' . $this->_var_bracket_regexp
|
||||||
@@ -131,7 +133,7 @@ class Smarty_Compiler extends Smarty {
|
|||||||
// #foo#
|
// #foo#
|
||||||
// "text"
|
// "text"
|
||||||
// "text"
|
// "text"
|
||||||
$this->_var_regexp = '(?:' . $this->_avar_regexp . '|' . $this->_qstr_regexp . ')';
|
$this->_var_regexp = '(?:' . $this->_avar_regexp . '|' . $this->_num_const_regexp . '|' . $this->_qstr_regexp . ')';
|
||||||
|
|
||||||
// matches valid object call (no objects allowed in parameters):
|
// matches valid object call (no objects allowed in parameters):
|
||||||
// $foo->bar
|
// $foo->bar
|
||||||
@@ -1589,6 +1591,14 @@ class Smarty_Compiler extends Smarty {
|
|||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
elseif(preg_match('!^' . $this->_num_const_regexp . '(?:' . $this->_mod_regexp . '*)$!', $val)) {
|
||||||
|
// numerical constant
|
||||||
|
preg_match('!^(' . $this->_num_const_regexp . ')('. $this->_mod_regexp . '*)$!', $val, $match);
|
||||||
|
if($match[2] != '') {
|
||||||
|
$this->_parse_modifiers($match[1], $match[2]);
|
||||||
|
return $match[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
elseif(preg_match('!^' . $this->_si_qstr_regexp . '(?:' . $this->_mod_regexp . '*)$!', $val)) {
|
elseif(preg_match('!^' . $this->_si_qstr_regexp . '(?:' . $this->_mod_regexp . '*)$!', $val)) {
|
||||||
// single quoted text
|
// single quoted text
|
||||||
preg_match('!^(' . $this->_si_qstr_regexp . ')('. $this->_mod_regexp . '*)$!', $val, $match);
|
preg_match('!^(' . $this->_si_qstr_regexp . ')('. $this->_mod_regexp . '*)$!', $val, $match);
|
||||||
|
Reference in New Issue
Block a user