change backtic syntax from $foo to $foo

This commit is contained in:
mohrt
2003-04-04 23:19:02 +00:00
parent da67d8edce
commit d169624a9b
3 changed files with 26 additions and 1 deletions

1
NEWS
View File

@@ -1,3 +1,4 @@
- change backtic syntax from $`foo` to `$foo` (Monte)
- recognize $foo[][] syntax inside embedded quotes without - recognize $foo[][] syntax inside embedded quotes without
backtics (Monte) backtics (Monte)
- name=123 is passed as an integer (not a string) to plugins now (messju) - name=123 is passed as an integer (not a string) to plugins now (messju)

View File

@@ -108,6 +108,30 @@
<SELECT name=company> <SELECT name=company>
{html_options values=$vals selected=$selected output=$output} {html_options values=$vals selected=$selected output=$output}
&lt;/SELECT&gt;</programlisting> &lt;/SELECT&gt;</programlisting>
</example>
</sect1>
<sect1 id="language.syntax.quotes">
<title>Embedding Vars in Double Quotes</title>
<para>
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.
</para>
<example>
<title>embedded quotes syntax</title>
<programlisting>
SYNTAX EXAMPLES:
{func var="test $foo test"} &lt-- sees $foo
{func var="test $foo_bar test"} &lt-- sees $foo_bar
{func var="test $foo[0] test"} &lt-- sees $foo[0]
{func var="test $foo[bar] test"} &lt-- sees $foo[bar]
{func var="test $foo.bar test"} &lt-- sees $foo (not $foo.bar)
{func var="test `$foo.bar` test"} &lt-- sees $foo.bar
PRACTICAL EXAMPLES:
{include file="subdir/$tpl_name.tpl"} &lt-- will replace $tpl_name with value
{cycle values="one,two,`$smarty.config.myval`"} &lt-- must have backticks</programlisting>
</example> </example>
</sect1> </sect1>

View File

@@ -1452,7 +1452,7 @@ class Smarty_Compiler extends Smarty {
function _expand_quoted_text($var_expr) function _expand_quoted_text($var_expr)
{ {
// if contains unescaped $, expand it // if contains unescaped $, expand it
if(preg_match_all('%(?<!\\\\)\$(?:\`' . $this->_dvar_guts_regexp . '\`|\w+(\[[a-zA-Z0-9]+\])*)%', $var_expr, $_match)) { if(preg_match_all('%(?:\`(?<!\\\\)\$' . $this->_dvar_guts_regexp . '\`)|(?:(?<!\\\\)\$\w+(\[[a-zA-Z0-9]+\])*)%', $var_expr, $_match)) {
$_match = $_match[0]; $_match = $_match[0];
rsort($_match); rsort($_match);
reset($_match); reset($_match);