boolean - How can I use a bool and bool condition in a mustache template?
问题描述
I am looking to use two conditions together to handle a display. If both a and b are true, then show something.
In JavaScript, we would write: if (a && b) { ... }
Moustache
{{#(one && two)}} // or #one && #two
<p>foobar</p>
{{/(one && two)}}
JSON
{
"one": "OK",
"two": "Yes"
}
解决方案
请记住
if (a && b) {
}
是相同的
if (a) {
if (b) {
}
}
所以你可以这样写你的 Mustach 模板:
胡子
{{#one}}
{{#two}}
<p>foobar</p>
{{/two}}
{{/one}}
推荐阅读
- regex - 仅包含两个大写字母的行的正则表达式
- node.js - 如何验证使用 multer 上传的文件的最小数量?
- c - 不明白这个错误代码是什么意思
- typescript - React Native with TypeScript and cucumber-js: Importing TypeScript Functions into Cucumber Step Definitions
- r - 在给定条件的情况下更改列中的行值
- php - Laravel PHP 异步
- c# - 我做了一个列表,想在 mvc5 中显示它,但出现错误。这是代码
- scala - Scalatra - 未找到:对象缩放
- python - Python - 计算存储在列表中的关键字出现在文本中的次数
- mongodb - MongoDB 条件查询取决于可能的日期