空格键:如何使用和/或在 if 语句中 [英] spacebars: how to use and / or in if statements

查看:97
本文介绍了空格键:如何使用和/或在 if 语句中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码:

 <div class="form-group {{#if afFieldIsInvalid name='latitude' OR name='longitude'}}has-error{{/if}}">......</div>

如何在空格键模板的 if 条件中使用 AND/OR ?

How can I use AND/OR in if conditions of spacebars templates ?

推荐答案

Spacebars 是 Handlebars 的扩展,它被设计为一种无逻辑的模板语言.

Spacebars is an extension of Handlebars, which is designed to be a logic-less template language.

解决办法是注册一个helper.对于一般情况,请参阅以下类似问题:

The solution is to register a helper. For the general case, see these similar questions:

在 Handlebars 模板中包含条件逻辑,还是只使用 javascript?

把手模板中的布尔逻辑

要在 Meteor 中定义助手,请使用 Template.registerHelper

To define helpers in Meteor, use Template.registerHelper

这篇关于空格键:如何使用和/或在 if 语句中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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