dimanche 20 septembre 2015

Getting a components block text inside the component

If you have a block component foo-bar which shows up in the template like this:

{{#foo-bar}}

  <span class='greeting'>Hello</span>
  <span class='person'>{{person}}</span>

{{/foo-bar}}

How can the foo-bar.js access the block string as html? I figured I could just do something to the effect of:

myBlockContent: Ember.computed(function() {
  return Ember.String.htmlSafe(this.$('div').html());
}

This returns a safe string but the {{person}} property has not be interpolated into the template.

I created a twiddle that sort of illustrates it (see console.log): twiddle




Aucun commentaire:

Enregistrer un commentaire