Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
combatentropy
on May 28, 2018
|
parent
|
context
|
favorite
| on:
Python’s For - Else
The Handlebars template engine works the way you're talking about. The "each" helper loops through an array. You can put in an "else" block for when the array is empty.
{{#each paragraphs}} <p>{{this}}</p> {{else}} <p class="empty">No content</p> {{/each}}
---
https://handlebarsjs.com/builtin_helpers.html
scardine
on May 28, 2018
|
next
[–]
Django templates also have such a clause but it is named "empty" instead of "else".
kchr
on May 28, 2018
|
prev
[–]
I like this ternary approach.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: