Templates 用let声明的大豆模板中的更新值
我有一个值绑定到一个来自配置文件的标志,我需要在我的模板中显示该文件。这不是真的就是假的 如果为true,则值需要为“x”(例如,但它是一个字符串) 如果为false,则值需要为“”(空) 请注意,我无法从配置中传入true或false值。我也不能忽略false上的值,它必须提供一个空字符串 我尝试过使用let的各种形式的if语句,但根据我对文档的解释,使用let声明的值不能更改(这没有意义) 这基本上就是我需要的:Templates 用let声明的大豆模板中的更新值,templates,closures,conditional,google-closure-templates,soy-templates,Templates,Closures,Conditional,Google Closure Templates,Soy Templates,我有一个值绑定到一个来自配置文件的标志,我需要在我的模板中显示该文件。这不是真的就是假的 如果为true,则值需要为“x”(例如,但它是一个字符串) 如果为false,则值需要为“”(空) 请注意,我无法从配置中传入true或false值。我也不能忽略false上的值,它必须提供一个空字符串 我尝试过使用let的各种形式的if语句,但根据我对文档的解释,使用let声明的值不能更改(这没有意义) 这基本上就是我需要的: {if $inputValue.value == 'true'} {l
{if $inputValue.value == 'true'}
{let $myVar: ($someValueThatExistsInMyTemplate) /}
{else}
{let $myVar: '' /}
{/if}
然后我将在模板中使用$myVar。但是,每当我尝试这样做时,都会出现以下错误:
Found references to data keys that are not declared in SoyDoc: [myVar]
我能做什么 使用三元运算符使其工作:
{let $dataParent: ($item.preferences.accordionOnOff.value == 'true') ? ($item.name) : '' /}