bootstrap-for-ember icon indicating copy to clipboard operation
bootstrap-for-ember copied to clipboard

notifications itemViewClass allowing complex templatating

Open c0urg3tt3 opened this issue 11 years ago • 0 comments

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.

c0urg3tt3 avatar Oct 11 '13 15:10 c0urg3tt3