So I have taken the 'is' helper block from here and modified it so that it register's it's helper through Ember using registerBoundHelper
The reason I did that is because I basically need a handlebars based 'switch' statement. The end result in my handlebars is as follows:
{{#is MyProperty 1}}
...Do something here...
{{/is}}
{{#is MyProperty 2}}
...Do something here...
{{/is}}
{{#is MyProperty 3}}
...Do something here...
{{/is}}
{{#is MyProperty 4}}
...Do something here...
{{/is}}
The is statement just does a simple comparison between 'MyProperty's value and a constant.
If I don't use 'registerBoundHelper' MyProperty gets passed through as the string literal 'MyProperty' and not it's value.
Now: This logic appears to work when I actually run it
The issue is that Ember throws the following error:
registerBoundHelper-generated helpers do not support use with Handlebars blocks.
Should I ignore this error and just continue on because it does appear to be working? Or should I try to rework the logic to not use a block?
You shouldn't ignore it because it isn't supported, if
MyProperty
were to change after the render has occurred it will break.Conditional helpers aren't supported (to many of our demise) in ember handlebars. The reason being is the core team wants this logic as a computed property instead of logic in the template.
IE
Controller
Template