[partially solved] JS switch equivalent in Spacebars

Is it possible to realize [JS switch equivalent][1]
[1]: http://www.w3schools.com/js/js_switch.asp
in Spacebars syntax? Like:

{{#switch color}}
  {{#case red}} {{> redTemplate}} {{/case}}
  {{#case blue}} {{> blueTemplate}} {{/case}}
{{/switch}}

Doesn’t answer your question, but you can have the switch in a helper instead and do something like:

{{> Template.dynamic template=mySwitchHelper}}
2 Likes

Guess I’ll have to stick with multiple If’s for now…

{{if equals color red}}
  {{>redTpl}}
{{#if}}
{{if equals color blue}}
  {{>blueTpl}}
{{#if}}

Dynamic templates work well. We have been using it. It is less clunky and more manageable than the multiple ifs in code.
Spacebars has a goal to reduce code in templates and push as much as possible into helpers/JS. So, using dynamic templates would be the right solution.