diff --git a/NEWS b/NEWS index dbc321d4..ea2364c2 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,4 @@ + - change backtic syntax from $`foo` to `$foo` (Monte) - recognize $foo[][] syntax inside embedded quotes without backtics (Monte) - name=123 is passed as an integer (not a string) to plugins now (messju) diff --git a/docs/designers.sgml b/docs/designers.sgml index 14dff91c..879de1d2 100644 --- a/docs/designers.sgml +++ b/docs/designers.sgml @@ -108,6 +108,30 @@ <SELECT name=company> {html_options values=$vals selected=$selected output=$output} </SELECT> + + + + Embedding Vars in Double Quotes + + Smarty will recognize assigned variables embedded in double quotes so long + as the variables contain only numbers, letters, underscores and brackets + []. With any other characters (period, object reference, etc.) the variable + must be surrounded by backticks. + + + embedded quotes syntax + +SYNTAX EXAMPLES: +{func var="test $foo test"} <-- sees $foo +{func var="test $foo_bar test"} <-- sees $foo_bar +{func var="test $foo[0] test"} <-- sees $foo[0] +{func var="test $foo[bar] test"} <-- sees $foo[bar] +{func var="test $foo.bar test"} <-- sees $foo (not $foo.bar) +{func var="test `$foo.bar` test"} <-- sees $foo.bar + +PRACTICAL EXAMPLES: +{include file="subdir/$tpl_name.tpl"} <-- will replace $tpl_name with value +{cycle values="one,two,`$smarty.config.myval`"} <-- must have backticks diff --git a/libs/Smarty_Compiler.class.php b/libs/Smarty_Compiler.class.php index a496297c..fa6fc3a3 100644 --- a/libs/Smarty_Compiler.class.php +++ b/libs/Smarty_Compiler.class.php @@ -1452,7 +1452,7 @@ class Smarty_Compiler extends Smarty { function _expand_quoted_text($var_expr) { // if contains unescaped $, expand it - if(preg_match_all('%(?_dvar_guts_regexp . '\`|\w+(\[[a-zA-Z0-9]+\])*)%', $var_expr, $_match)) { + if(preg_match_all('%(?:\`(?_dvar_guts_regexp . '\`)|(?:(?