The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/packages/rocketchat-ui/client/lib/parentTemplate.js

18 lines
457 B

/**
* Get the parent template instance
* @param {Number} [levels] How many levels to go up. Default is 1
* @returns {Blaze.TemplateInstance}
*/
Blaze.TemplateInstance.prototype.parentTemplate = function(levels) {
let view = Blaze.currentView;
if (typeof levels === 'undefined') {
levels = 1;
}
while (view) {
if (view.name.substring(0, 9) === 'Template.' && !(levels--)) {
return view.templateInstance();
}
view = view.parentView;
}
};