Created
July 5, 2014 08:57
-
-
Save leandrowd/8cebda04b85c7d61ece2 to your computer and use it in GitHub Desktop.
Ember handlebars helper to avoid multiple metamorph tags inside an each block
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
/** | |
* Ember handlebars group helper | |
* | |
* This helper will solve most of problems refering to metamorph | |
* tags inside a each block. You should use it when you don't need the two-way | |
* data binding inside your loop. | |
* | |
* Adapted from: https://github.com/emberjs/group-helper | |
* To works with ember-cli the filename should have a hyphen ('group-render') | |
*/ | |
var get = Ember.get, set = Ember.set; | |
export default function(options) { | |
var data = options.data, | |
fn = options.fn, | |
view = data.view, | |
childView; | |
childView = view.createChildView(Ember._MetamorphView, { | |
context: get(view, 'context'), | |
template: function(context, options) { | |
options.data.insideGroup = true; | |
return fn(context, options); | |
} | |
}); | |
view.appendChild(childView); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment