handlebar js custom helper for else if

handlebars.js

Solution

Since Handlebars 3.0 the syntax described by OP does work out of the box! See: https://github.com/wycats/handlebars.js/pull/892 for more information.

Note: For Ember, since version 1.10 and up this does work too. See also: http://emberjs.com/blog/2015/02/07/ember-1-10-0-released.html#toc_chained-else-blocks

Problem

I have started using Handlebars.js. It seems that there is no built in conditionals like else if. I want to have something like this ``` {{#if type.one }} do something ... IF {{else if type.two}} do something ... ELSE IF {{else}} do something ... ELSE {{/if}} ``` But this doesn't work. How do I do ELSE IF with handlebars? Is writing a custom helper is the only option ? If yes then please provide some pointers to write this helper.

Original source