diff --git a/NEWS b/NEWS index 5e6df1c7..a399ba26 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ + - make $smarty.const.FOO compile to "FOO", and not to "constant('foo')". + this is less code and a little faster execution. note that undefined + constants are now displayed as the constant's name. (messju) - make block functions and registered objects' block methods use a local variable for block_content instead of a property of $smarty (messju) - fix escaping in the generated code that calls smarty_core_load_plugins diff --git a/libs/Smarty_Compiler.class.php b/libs/Smarty_Compiler.class.php index fe572d71..7d46eb44 100644 --- a/libs/Smarty_Compiler.class.php +++ b/libs/Smarty_Compiler.class.php @@ -2031,8 +2031,12 @@ class Smarty_Compiler extends Smarty { return; } array_shift($indexes); - $_val = $this->_parse_var_props(substr($indexes[0],1)); - $compiled_ref = '@constant(' . $_val . ')'; + if (preg_match('!^\.\w+$!', $indexes[0])) { + $compiled_ref = '@' . substr($indexes[0], 1); + } else { + $_val = $this->_parse_var_props(substr($indexes[0], 1)); + $compiled_ref = '@constant(' . $_val . ')'; + } $_max_index = 1; break;