This repository has been archived by the owner on Nov 11, 2017. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #215 from sly7-7/fix-registerHelper-lookup
Add missing cross-version helper registration
- Loading branch information
Showing
2 changed files
with
35 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
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); | ||
} | ||
} |