当前位置: 动力学知识库 > 问答 > 编程问答 >

pug - Coalesce a value in Meteor Jade

问题描述:

In a template, I do this

if description

p.editable= description

else

p.editable

| No description. Click to edit.

I wonder if there's a way to coalesce a value like in JavaScript:

p.editable #{description || 'Click to edit'}

But this is incorrect syntax in Jade

网友答案:

Unfortunately jade doesn't support exactly what you're trying to achieve.

Best way would be to create a variable in your template like so:

- var desc = description || "Click to edit"
p.editable #{desc}
分享给朋友:
您可能感兴趣的文章:
随机阅读: