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.

Smarty可以识别嵌入在双引号中的变量,只要此变量只包含数字、字母、下划线和中括号[].对于其他的符号(句号、对象相关的,等等)此变量必须用两个'`'(此符号和‘ ~ '在同一个键上,一般在ESC键下面一个键上)包住。

 

Example 3-4. embedded quotes syntax

例 3-4.双引号里值的嵌入语法

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