Skip to content

Instantly share code, notes, and snippets.

@richsilv
Created August 27, 2015 12:18
Show Gist options
  • Save richsilv/791c657eb9371ce78af9 to your computer and use it in GitHub Desktop.
Save richsilv/791c657eb9371ce78af9 to your computer and use it in GitHub Desktop.
Template instance `get` method for searching Template heirarchy for a named property
Blaze.TemplateInstance.prototype.get = function(key) {
var checkForKey = function(view) {
if (view && view.template instanceof Blaze.Template) {
var template = view.templateInstance()
if (typeof template[key] !== 'undefined') return template[key]
}
if (view.parentView) return checkForKey(view.parentView)
}
return checkForKey(this.view)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment