twigkit / tempo

Tempo is an easy, intuitive JavaScript rendering engine that enables you to craft data templates in pure HTML.
http://tempojs.com/
Apache License 2.0
709 stars 73 forks source link

Feature request: {% elsif ... %} #83

Open 2is10 opened 10 years ago

2is10 commented 10 years ago

Would be great to be able to chain conditionals more succinctly. It's currently verbose, error prone, and a maintenance headache, since conditions have to be repeated:

{% if X %}
    ...
{% endif %}{% if !X && Y %}
    ...
{% endif %}{% if !X && !Y && Z %}
    ...
{% endif %}{% if !X && !Y && !Z %}
    ...
{% endif %}

The same could be written more succinctly something like this:

{% if X %}
    ...
{% elsif Y %}
    ...
{% elsif Z %}
    ...
{% else %}
    ...
{% endif %}
mrolafsson commented 10 years ago

I agree, this is a very worthwhile feature. See my first reply.