Displaying data with template helpers
Each template can have functions, which are called template
helpers, and they can be used inside the template and child templates.
In addition to our custom helper functions, there are three callback functions that are called when the template is created, rendered, and destroyed. To display data with template helpers, perform the following steps:
To see the three callback functions in action, let's create a file called
home.js
and save it to ourmy-meteor-blog/client/templates/
folder with the following code snippet:Template.home.created = function(){ console.log('Created the home template'); }; Template.home.rendered = function(){ console.log('Rendered the home template'); }; Template.home.destroyed = function(){ console.log('Destroyed the home template'); };
If we now open the console of our browser, we will see the first two callbacks are being fired. The last one will only fire if we dynamically remove the template.
To display data in the
home...