[solved] How to get template name in tpl callback?

Hey all! This sd be an easy one :smile:
How can I get template name in onRendered callback?

This is not as easy as you hoped…

this.view.name

will get you the view name of the current template instance

The reason its not straight forward is that you never need to address a template by it’s name after it is instantiated - you would use the Template.instance() method, or in the template callbacks the this keyword, which is a shortcut to the template instance

e.g.

Template.toolbar.onRendered(function () {
    console.log(this.view.name)
});

logs ‘Template.toolbar’

1 Like

Works nice and simple. Thanks a lot)