Skip to content
This repository has been archived by the owner on Nov 11, 2017. It is now read-only.

Commit

Permalink
Merge pull request #215 from sly7-7/fix-registerHelper-lookup
Browse files Browse the repository at this point in the history
Add missing cross-version helper registration
  • Loading branch information
stefanpenner committed Mar 25, 2015
2 parents aefb20f + 1c0549c commit 2c31148
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 8 deletions.
10 changes: 2 additions & 8 deletions addon/helper.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
import Ember from 'ember';
import EmberListView from './list-view';
import EmberVirtualListView from './virtual-list-view';

import registerHelper from './register-helper';

export var EmberVirtualList = createHelper(EmberVirtualListView);
export var EmberList = createHelper(EmberListView);

export function registerListViewHelpers() {
var registerHelper;
if (Ember.HTMLBars) {
// registerHelper was used for some 1.10-beta's and _registerHelper is for 1.10.0 final.
registerHelper = Ember.HTMLBars._registerHelper || Ember.HTMLBars.registerHelper;
} else {
registerHelper = Ember.Handlebars.registerHelper;
}
registerHelper('ember-list', EmberList);
registerHelper('ember-virtual-list', EmberVirtualList);
}
Expand Down
33 changes: 33 additions & 0 deletions addon/register-helper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import Ember from 'ember';

function registerHelperIteration1(name, helperFunction) {
//earlier versions of ember with htmlbars used this
Ember.HTMLBars.helpers[name] = helperFunction;
}

function registerHelperIteration2(name, helperFunction) {
//registerHelper has been made private as _registerHelper
//this is kept here if anyone is using it
Ember.HTMLBars.registerHelper(name, helperFunction);
}

function registerHelperIteration3(name, helperFunction) {
//latest versin of ember uses this
Ember.HTMLBars._registerHelper(name, helperFunction);
}

export default function registerHelper(name, helperFunction) {
if (Ember.HTMLBars) {
if (Ember.HTMLBars._registerHelper) {
if (Ember.HTMLBars.helpers) {
registerHelperIteration1(name, helperFunction);
} else {
registerHelperIteration3(name, helperFunction);
}
} else if (Ember.HTMLBars.registerHelper) {
registerHelperIteration2(name, helperFunction);
}
} else if (Ember.Handlebars) {
Ember.Handlebars.helper(name, helperFunction);
}
}

0 comments on commit 2c31148

Please sign in to comment.