diff --git a/lib/expressions.js b/lib/expressions.js index 8ce0804..200ae53 100644 --- a/lib/expressions.js +++ b/lib/expressions.js @@ -409,20 +409,20 @@ FnExpression.prototype._lookupParent = function(context) { // Lookup function in the model var segments = this.parentSegments; var parent = (segments) ? lookup(segments, context.controller.model.data) : undefined; - if (parent && parent[this.lastSegment]) return parent; - // Lookup function on current controller + if (parent && typeof parent[this.lastSegment] == 'function') return parent; + // Otherwise lookup function on current controller var controller = context.controller; parent = (segments) ? lookup(segments, controller) : controller; - if (parent && parent[this.lastSegment]) return parent; + if (parent && typeof parent[this.lastSegment] == 'function') return parent; // Otherwise lookup function on page var page = controller.page; if (controller !== page) { parent = (segments) ? lookup(segments, page) : page; - if (parent && parent[this.lastSegment]) return parent; + if (parent && typeof parent[this.lastSegment] == 'function') return parent; } // Otherwise lookup function on global parent = (segments) ? lookup(segments, global) : global; - if (parent && parent[this.lastSegment]) return parent; + if (parent && typeof parent[this.lastSegment] == 'function') return parent; // Throw if not found throw new Error('Function not found for: ' + this.segments.join('.')); };