mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 10:24:26 +02:00
allow null as function attribute value
This commit is contained in:
2
NEWS
2
NEWS
@@ -1,3 +1,5 @@
|
|||||||
|
- allow null as function attribute value
|
||||||
|
(Andr<64> Rabold, Monte)
|
||||||
- support $foo->bar[index] syntax (Monte)
|
- support $foo->bar[index] syntax (Monte)
|
||||||
- add get_registered_object function (messju, Monte)
|
- add get_registered_object function (messju, Monte)
|
||||||
- treat unrecognized param attribute syntax as string (Monte)
|
- treat unrecognized param attribute syntax as string (Monte)
|
||||||
|
@@ -53,7 +53,7 @@ class Smarty_Compiler extends Smarty {
|
|||||||
var $_capture_stack = array(); // keeps track of nested capture buffers
|
var $_capture_stack = array(); // keeps track of nested capture buffers
|
||||||
var $_plugin_info = array(); // keeps track of plugins to load
|
var $_plugin_info = array(); // keeps track of plugins to load
|
||||||
var $_init_smarty_vars = false;
|
var $_init_smarty_vars = false;
|
||||||
var $_permitted_tokens = array('true','false','yes','no','on','off');
|
var $_permitted_tokens = array('true','false','yes','no','on','off','null');
|
||||||
var $_db_qstr_regexp = null; // regexps are setup in the constructor
|
var $_db_qstr_regexp = null; // regexps are setup in the constructor
|
||||||
var $_si_qstr_regexp = null;
|
var $_si_qstr_regexp = null;
|
||||||
var $_qstr_regexp = null;
|
var $_qstr_regexp = null;
|
||||||
@@ -659,9 +659,12 @@ class Smarty_Compiler extends Smarty {
|
|||||||
|
|
||||||
$arg_list = array();
|
$arg_list = array();
|
||||||
$attrs = $this->_parse_attrs($tag_args);
|
$attrs = $this->_parse_attrs($tag_args);
|
||||||
|
|
||||||
foreach ($attrs as $arg_name => $arg_value) {
|
foreach ($attrs as $arg_name => $arg_value) {
|
||||||
if (is_bool($arg_value))
|
if (is_bool($arg_value))
|
||||||
$arg_value = $arg_value ? 'true' : 'false';
|
$arg_value = $arg_value ? 'true' : 'false';
|
||||||
|
if (is_null($arg_value))
|
||||||
|
$arg_value = 'null';
|
||||||
$arg_list[] = "'$arg_name' => $arg_value";
|
$arg_list[] = "'$arg_name' => $arg_value";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1342,9 +1345,11 @@ class Smarty_Compiler extends Smarty {
|
|||||||
/* We booleanize the token if it's a non-quoted possible
|
/* We booleanize the token if it's a non-quoted possible
|
||||||
boolean value. */
|
boolean value. */
|
||||||
if (preg_match('!^(on|yes|true)$!', $token)) {
|
if (preg_match('!^(on|yes|true)$!', $token)) {
|
||||||
$token = true;
|
$token = 'true';
|
||||||
} else if (preg_match('!^(off|no|false)$!', $token)) {
|
} else if (preg_match('!^(off|no|false)$!', $token)) {
|
||||||
$token = false;
|
$token = 'false';
|
||||||
|
} else if ($token == 'null') {
|
||||||
|
$token = 'null';
|
||||||
} else if (!preg_match('!^' . $this->_obj_call_regexp . '|' . $this->_var_regexp . '(?:' . $this->_mod_regexp . ')?$!', $token)) {
|
} else if (!preg_match('!^' . $this->_obj_call_regexp . '|' . $this->_var_regexp . '(?:' . $this->_mod_regexp . ')?$!', $token)) {
|
||||||
/* treat as a string, double-quote it escaping quotes */
|
/* treat as a string, double-quote it escaping quotes */
|
||||||
$token = '"'.addslashes($token).'"';
|
$token = '"'.addslashes($token).'"';
|
||||||
@@ -1368,7 +1373,7 @@ class Smarty_Compiler extends Smarty {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->_parse_vars_props($attrs);
|
$this->_parse_vars_props($attrs);
|
||||||
|
|
||||||
return $attrs;
|
return $attrs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -53,7 +53,7 @@ class Smarty_Compiler extends Smarty {
|
|||||||
var $_capture_stack = array(); // keeps track of nested capture buffers
|
var $_capture_stack = array(); // keeps track of nested capture buffers
|
||||||
var $_plugin_info = array(); // keeps track of plugins to load
|
var $_plugin_info = array(); // keeps track of plugins to load
|
||||||
var $_init_smarty_vars = false;
|
var $_init_smarty_vars = false;
|
||||||
var $_permitted_tokens = array('true','false','yes','no','on','off');
|
var $_permitted_tokens = array('true','false','yes','no','on','off','null');
|
||||||
var $_db_qstr_regexp = null; // regexps are setup in the constructor
|
var $_db_qstr_regexp = null; // regexps are setup in the constructor
|
||||||
var $_si_qstr_regexp = null;
|
var $_si_qstr_regexp = null;
|
||||||
var $_qstr_regexp = null;
|
var $_qstr_regexp = null;
|
||||||
@@ -659,9 +659,12 @@ class Smarty_Compiler extends Smarty {
|
|||||||
|
|
||||||
$arg_list = array();
|
$arg_list = array();
|
||||||
$attrs = $this->_parse_attrs($tag_args);
|
$attrs = $this->_parse_attrs($tag_args);
|
||||||
|
|
||||||
foreach ($attrs as $arg_name => $arg_value) {
|
foreach ($attrs as $arg_name => $arg_value) {
|
||||||
if (is_bool($arg_value))
|
if (is_bool($arg_value))
|
||||||
$arg_value = $arg_value ? 'true' : 'false';
|
$arg_value = $arg_value ? 'true' : 'false';
|
||||||
|
if (is_null($arg_value))
|
||||||
|
$arg_value = 'null';
|
||||||
$arg_list[] = "'$arg_name' => $arg_value";
|
$arg_list[] = "'$arg_name' => $arg_value";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1342,9 +1345,11 @@ class Smarty_Compiler extends Smarty {
|
|||||||
/* We booleanize the token if it's a non-quoted possible
|
/* We booleanize the token if it's a non-quoted possible
|
||||||
boolean value. */
|
boolean value. */
|
||||||
if (preg_match('!^(on|yes|true)$!', $token)) {
|
if (preg_match('!^(on|yes|true)$!', $token)) {
|
||||||
$token = true;
|
$token = 'true';
|
||||||
} else if (preg_match('!^(off|no|false)$!', $token)) {
|
} else if (preg_match('!^(off|no|false)$!', $token)) {
|
||||||
$token = false;
|
$token = 'false';
|
||||||
|
} else if ($token == 'null') {
|
||||||
|
$token = 'null';
|
||||||
} else if (!preg_match('!^' . $this->_obj_call_regexp . '|' . $this->_var_regexp . '(?:' . $this->_mod_regexp . ')?$!', $token)) {
|
} else if (!preg_match('!^' . $this->_obj_call_regexp . '|' . $this->_var_regexp . '(?:' . $this->_mod_regexp . ')?$!', $token)) {
|
||||||
/* treat as a string, double-quote it escaping quotes */
|
/* treat as a string, double-quote it escaping quotes */
|
||||||
$token = '"'.addslashes($token).'"';
|
$token = '"'.addslashes($token).'"';
|
||||||
@@ -1368,7 +1373,7 @@ class Smarty_Compiler extends Smarty {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->_parse_vars_props($attrs);
|
$this->_parse_vars_props($attrs);
|
||||||
|
|
||||||
return $attrs;
|
return $attrs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user