handlebars-rust icon indicating copy to clipboard operation
handlebars-rust copied to clipboard

Chained else expression

Open sunng87 opened this issue 10 years ago • 9 comments

Support syntax

{{#if ...}}
{{else if ...}}
{{else}}
{{/if}}

https://github.com/wycats/handlebars.js/pull/892

sunng87 avatar Feb 12 '15 07:02 sunng87

Is there any workaround currently? I'd like to use this, but unfortunately I'm currently too busy to contribute.

golddranks avatar Dec 13 '16 21:12 golddranks

Oops the obvious workaround works. I had an unrelated syntax error because of a typo, which made me think that nesting wouldn't work.

{{#if var1}}
    ...
{{ else }}{{#if var2}}
    ...
{{ else }}
    ...
{{/if}}{{/if}}

golddranks avatar Dec 13 '16 21:12 golddranks

Yes.

To support chained else, we may need an update in current parser and helper definition because {{else if ...}} is incompatible with current model.

sunng87 avatar Dec 14 '16 02:12 sunng87

Hey @sunng87, any progress on this issue?

rousan avatar Apr 21 '20 13:04 rousan

@rousan sorry, there is no progress for now.

sunng87 avatar Apr 21 '20 14:04 sunng87

so, is there any way to add some patches like adding a block helper? It would very helpful then.

rousan avatar Apr 21 '20 16:04 rousan

@rousan the helper system is totally open. You can register you own block/inline helpers with our API. Checkout examples if you like.

For this chained else, some work needs to be done on the parser and our template structure to support chained inverse template segment. I will probably add support in future releases.

sunng87 avatar Apr 22 '20 02:04 sunng87

@rousan the helper system is totally open. You can register you own block/inline helpers with our API. Checkout examples if you like.

For this chained else, some work needs to be done on the parser and our template structure to support chained inverse template segment. I will probably add support in future releases.

Anxiously waiting for this feature! Any updates?

shujaatak avatar Nov 30 '21 11:11 shujaatak

@shujaatak Unfortunately there is no progress for this feature. Contributions are welcomed for this.

sunng87 avatar Nov 30 '21 11:11 sunng87

Any updates?

jqiris avatar Jan 16 '24 14:01 jqiris

Fixed in #629

sunng87 avatar Jan 16 '24 15:01 sunng87

https://crates.io/crates/handlebars version not change?

jqiris avatar Jan 16 '24 15:01 jqiris

Released in 5.1.0

sunng87 avatar Jan 17 '24 05:01 sunng87