I've noticed that many template engines have a mechanism for detecting that a loop is not occurring.
Although their names and syntax vary, they all have this similar structure.
For example:
- Jinja
{% for user in users %}
{{ user }}
{% else %}
This is only evaluated if `users` is empty
{% endfor %}
- Jade
- var users = [];
ul
each user in users
li= val
else
li This is only evaluated if `users` is empty
- Hugo
{{ range $users }}
{{ . }}
{{ else }}
This is only evaluated if $users is empty
{{ end }}
But I have hardly seen similar constructs in general-purpose programming languages.
Notice: Python does not have this structure, these languages implement no-run
detection, while python implements no-break
detection.
What causes the disagreement between template language authors and general-purpose language authors?