Closed Alino closed 9 years ago
You should probably not be using this approach with Blaze Components. If you move to Blaze Components, it is easier and better to have a template helper on your base class as a method, which will then be available to all your child components.
You cannot directly access Template
. Read the section in the README about what you are doing.
But in your case the easiest way to do it is to just do:
Template.registerHelper('render', function () {
var template = BlazeLayout._getTemplate(this.name, Template.instance);
return template || null;
});
BTW, this is really bad because it will recreate a template instance/component every time the data context of your helper changes. This is really not efficient and this is why global helpers as well are discouraged, especially for such things where you are creating templates/components.
You might be interested in looking into #21, which has a patch to make this || null
unnecessary.
thank you again, I appreciate your answer, I will stop using this approach.
I have this global helper so I can load templates if they exists and do nothing if they don't: (idea from this article)
but if I call a blaze component template with this approach the template is loaded but blaze component functionality is not. Is there any workaround on how to make this work please?