在handlebars.js中是否有三元运算符? [英] Is there a ternary operator in handlebars.js?

查看:259
本文介绍了在handlebars.js中是否有三元运算符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在把手中,是否有三元操作符?我不是指 if else ;我的意思是像 a == true? a:b

解决方案

如果你有自己的帮手,真的想。像 ternary(a == true,a,b)。有关更多信息,请参阅文档。从m90的想法不是手柄背后的想法。这个想法是在模板中没有明确的代码,只需要调用助手和对象。


In Handlebars, is there a ternary operator? I don't mean if else; I mean like a == true ? "a" : "b".

解决方案

You can build your own helper in handlbars if you really want to. Something like ternary(a==true, "a", "b"). For more information on that see the documentation. The idea from m90 is not the idea behind handlebars. The idea is to not have explicit code in your templates, only calls to helpers and objects.

这篇关于在handlebars.js中是否有三元运算符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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