问题描述:

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}
相关阅读:
Top