meteor-template-var
meteor-template-var copied to clipboard
Feature request: accessing parent template variable
I think this package is the natural place for a function everyone uses (see below), nicely integrated with the package API.
// Returns an ancestor instance of the current template instance (by name)
// See
// https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/meteor-core/H9XUndnLpf0/N_hp69p9SsEJ
Blaze.TemplateInstance.prototype.parentInstance = function (templateName) {
if (! /^Template\./.test(templateName))
templateName = 'Template.' + templateName;
var view = this.view;
while (view = view.parentView)
if (view.name === templateName)
return view.templateInstance();
};
Something like this: https://github.com/aldeed/meteor-template-extension#templategetfieldname