Reputation: 75774
If item.description is undefined or empty, I want to default to 'No description':
I've tried the following:
<%-: ( item.description | markdown ) || '<p>No description</p>' %>
<%-: ( item.description || 'No description' ) | markdown %>
What else can I do?
Upvotes: 1
Views: 5556
Reputation: 11
I'm wondering the code with your question, why the pre-tag with ejs template expression is "<%-" not the "<%="
(the output or value assignment output) or the "<%=:"
(the filter output) signature?
BTW, the filter invoke signature is the single vertical bar not double, and you can invoke any times with what you want...
Upvotes: 1
Reputation: 123523
Not sure if you can mix ||
with the |
of EJS' filters, but you can add a filter to accomplish it:
ejs.filters.or = function (arg, sub) {
return arg || sub;
};
<%-: item.description | or:'No description' | markdown %>
Upvotes: 2