bootstrap-for-ember
bootstrap-for-ember copied to clipboard
notifications itemViewClass allowing complex templatating
as i want to add action like "cancel change" or "try again" in notification i saw that they only allow string.
what i want is rendering something like
congratulation ! <a href="#" {{action 'undo'}}>cancel</a>
so looking at the notification code and saw
template: Ember.Handlebars.compile('{{view.content.message}}')
i replaced the previous by
templateBinding: 'content.message'
and i use notification
var hbs = "congratulation ! <a href="#" {{action 'undo'}}>cancel</a>"
var notif = Ember.Handlebars.compile(hbs);
Bootstrap.NM.push(notif, 'success');
in some way that could end at something like
templateBinding: 'customTemplate',
customTemplate: function() {
var message = this.get('content.message');
if (/{{/.test(message)) {
// normal compile
return Ember.Handlebars.compile(message);
}
if (/</.test(message)) {
// allow string + html
return Ember.Handlebars.compile('{{{view.content.message}}}');
}
// string only
return Ember.Handlebars.compile('{{view.content.message}}');
}.property('content.message')
allowing devs to use notifications like before but with more templating capabilities.
i can PR if needed.