mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
change backtic syntax from $foo
to $foo
This commit is contained in:
1
NEWS
1
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)
|
||||
|
@@ -108,6 +108,30 @@
|
||||
<SELECT name=company>
|
||||
{html_options values=$vals selected=$selected output=$output}
|
||||
</SELECT></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"} <-- 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</programlisting>
|
||||
</example>
|
||||
</sect1>
|
||||
|
||||
|
@@ -1452,7 +1452,7 @@ class Smarty_Compiler extends Smarty {
|
||||
function _expand_quoted_text($var_expr)
|
||||
{
|
||||
// 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];
|
||||
rsort($_match);
|
||||
reset($_match);
|
||||
|
Reference in New Issue
Block a user