Panman82 / ember-bootstrap-switch

An ember-cli addon to import bootstrap-switch and provide an Ember component.
MIT License
5 stars 4 forks source link

Support Handlebars SafeString as labelText #10

Closed jelhan closed 8 years ago

jelhan commented 8 years ago

Currently SafeString objects is not supported as labelText property. That's annoying if you use an intl library which returns SafeString objects. Could use get helper as a work-a-round but native support would be nicer. Should be safe to just call toString on labelText property.

{{bootstrap-switch
  labelText=(get (t 'label.translation') 'string')
}}
Panman82 commented 8 years ago

Re-opening to confirm this will work for you. Take a look at the recent commit f9e9925ee29cc5447cbfd1b1c58c4de87e663613 Let me know what you think.

jelhan commented 8 years ago

Idea looks good, but there's a bug.

https://github.com/Panman8201/ember-bootstrap-switch/blob/f9e9925ee29cc5447cbfd1b1c58c4de87e663613/addon/components/bootstrap-switch.js#L37

Ember.assert('Object must have a .toString() method!', !value.toString);
// !"string".toString = false
// !(new String("string")).toString = false

Ember.assert throws an exception if condition is not met. So it should be the other way round. But I would suggest to test that toString is a function.

Ember.assert('Object must have a .toString() method!', typeof value.toString === 'function');

https://github.com/jelhan/ember-bootstrap-switch/commit/32c8a65fc87f49db7135f296f448ede7bde66ae8

Panman82 commented 8 years ago

Works for me, care to submit a PR? I'll release after that.

Panman82 commented 8 years ago

Released as 1.13.1, thanks for your help.