如果条件,灰尘 [英] Dust if condition

查看:127
本文介绍了如果条件,灰尘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果情况如此,我遇到了灰尘问题。我有部分指向2个不同的灰尘模板,具体取决于国家/地区代码

  {>收据/ merchantInfo / merchantInfo_ { countryCode}/} 

我正在尝试制作if else条件,以确定是否 {countryCode} 是美国。
示例:

  {@ if cond ='{countryCode}'=='US'} 
< p>是国家代码US< / p>
{:else}
< p>不是国家/地区代码US< / p>
{/ if}

这不起作用。任何人都知道我哪里出错了?

解决方案

@if helper因为潜在的安全漏洞而被弃用(它在条件上使用eval)。我建议改为使用 @eq 助手。

  {@ eq key = countryCode value =US} 
< p>是国家代码US< / p>
{:else}
< p>不是国家/地区代码US< / p>
{/ eq}

如果这不起作用,请确保countryCode可用于您的上下文(您可以使用 {@ contextDump /} )。


I'm having trouble with a dust if condition. I have a partial that points to 2 different dust templates depending on the Country code

{>"receipt/merchantInfo/merchantInfo_{countryCode}"/}

I'm trying to make an if else condition that will figure out if the {countryCode} is US. Example:

{@if cond="'{countryCode}' == 'US'"}
<p>is country code US</p>
{:else}
<p>is NOT country code US</p>
{/if}

This isn't working. Anyone have an idea where I went wrong with this?

解决方案

The @if helper has been deprecated because of a potential security hole (it uses eval on the condition). I would recommend using the @eq helper instead.

{@eq key=countryCode value="US"}
  <p>is country code US</p>
{:else}
  <p>is NOT country code US</p>
{/eq}

If that doesn't work, make sure countryCode is available in your context (you can use {@contextDump/} for that).

这篇关于如果条件,灰尘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆