forked from iron-meteor/iron-dynamic-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
blaze_overrides.js
32 lines (29 loc) · 1.28 KB
/
blaze_overrides.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*****************************************************************************/
/* Imports */
/*****************************************************************************/
var assert = Iron.utils.assert;
var get = Iron.utils.get;
/*****************************************************************************/
/* Blaze Overrides */
/*****************************************************************************/
/**
* Adds ability to inject lookup hosts into views that can participate in
* property lookup. For example, iron:controller or iron:component could make
* use of this to add methods into the lookup chain. If the property is found,
* a function is returned that either returns the property value or the result
* of calling the function (bound to the __lookupHost__).
*/
var origLookup = Blaze.View.prototype.lookup;
Blaze.View.prototype.lookup = function (name /*, args */) {
var host;
host = DynamicTemplate.findLookupHostWithHelper(Blaze.getView(), name);
if (host) {
return function callLookupHostHelper (/* args */) {
var helper = get(host, 'constructor', '_helpers', name);
var args = [].slice.call(arguments);
return (typeof helper === 'function') ? helper.apply(host, args) : helper;
}
} else {
return origLookup.apply(this, arguments);
}
};