How can I use reactive template variables in an anonymous function within the template rendered function? (I want to keep it reactive).
Template.templateName.rendered = function() {
function testFunction(){
//Print the field 'title' associated with the current template
console.log(this.data.title);
}
});
First it seems you are using an ancient version of meteor. The syntax should be Template.name.onRendered(callback). Second you don’t have to use Template.currentData() inside an onRendered/onCreated/onDestroyed callback, this.data is sufficient. And at last, in the your example this refers to the function scope not to the template scope, you’ll either have to var self = this in parent scope or use ES5 fat arrow functions.