When using a conditional in ember, is it possible to have an OR
?
{{#if foo OR bar}}
or
{{#if foo || bar}}
There doesn't seem to be anything on it in the docs.
You should move the logic to your controller
App.SomeController = Em.Controller.extend({
foo: true,
bar: false,
fooOrBar: Em.computed.or('foo', 'bar')
});
Leaving the template logic to a minimum
{{#if fooOrBar}}
Use https://github.com/jmurphyau/ember-truth-helpers:
ember install ember-truth-helpers
Then you can say
{{#if (or foo bar)}}
Depending on your perspective, Kingpin2k's answer is a bit out of date. Previously, the community's understanding was that templates should be largely free of logic. Overtime, our viewpoint has shifted towards putting more declarative logic in templates-- ember-composable-helpers is a great example of this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With