Timmie Sarjanen
Timmie Sarjanen

Reputation: 411

Handlebars block helper inside quotes

don't know if block helper is the right name but hope you get the point.

In Ember 1.8.0-beta.2 i can not do

<img src="{{url}}">

Chrome gives me:

Uncaught TypeError: Cannot read property 'parentNode' of null
Uncaught TypeError: Cannot set property 'profileNode' of undefined

And Firefox gives me:

TypeError: ref is null
var parent = ref.parentNode;

The error comes from vendor.js

  hydrateMorphs: function () {
    var childViews = this.childViews;
    var el = this._element;
    for (var i=0,l=childViews.length; i<l; i++) {
      var childView = childViews[i];
      var ref = el.querySelector('#morph-'+i);
      var parent = ref.parentNode; // This line

      childView._morph = this.dom.insertMorphBefore(parent, ref);
      parent.removeChild(ref);
    }
  }

I know that i simply can do a handlebars helper to output the img tag with right src but i want to be able to use the {{url}} to set a divs background property aswell.
(the url property is just a simplified version. In my app i have a helper thats takes an array of images and maxWidth to to give me the best picture depending on the width. But {{url}} does not work either)

Upvotes: 0

Views: 1625

Answers (2)

Timmie Sarjanen
Timmie Sarjanen

Reputation: 411

forgot that I just can use unbound:

<img src="{{unbound url}}">

Upvotes: 1

stfcodes
stfcodes

Reputation: 1380

You can't use that syntax in ember handlebars. The accepted one is bind-attr.

Usage examples: http://emberjs.com/guides/templates/binding-element-attributes/

More info: http://www.emberist.com/2012/04/06/bind-and-bindattr.html

Upvotes: 0

Related Questions