I have code like this that I am going to repeat a lot:
<div>
{{#if sender.isContact}}
<a {{action showContact sender href=true}}>{{unbound sender.displayName}}</a>
{{else}}
<a {{action showUser sender href=true}}>{{unbound sender.displayName}}</a>
{{/if}}
</div>
THe only bit that changes is the action that the will be called.
How would I create a handlebars helper method to dry this up?
The creation of custom helpers is described pretty well in the Templates section of the Ember.js Guides.
You can also have a look at how the {{action}} helper in the Code and merge the parts you need for your own helper.
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