meteor-template-var icon indicating copy to clipboard operation
meteor-template-var copied to clipboard

Feature request: accessing parent template variable

Open steph643 opened this issue 9 years ago • 1 comments

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();
};

steph643 avatar Sep 19 '15 15:09 steph643

Something like this: https://github.com/aldeed/meteor-template-extension#templategetfieldname

steph643 avatar Sep 19 '15 16:09 steph643