我想知道如何在meteor-jade中关闭if else语句,例如:
if foo
html elements here
else
html elements here
我想要实现的是
if foo
html elements here
else
html elements here
html elements also here but it should be outside of the else statement and indented.
答案 0 :(得分:1)
由于在Jade缩进被解释为包含,因此您不能将这些元素对齐。要将一个元素放在if / else语句之外,你需要取消它:
if daytime
yellow html elements
else
blue html elements
green html elements
如果您希望green
html元素为yellow
或blue
元素的子元素,则根据daytime
值,您可以使用mixin并传递一个块:
mixin color(daytime)
if daytime
yellow
if block
block
else
blue
if block
block
+color(daytime)
green html elements