Adding and using templates in Meteor is a great way to speed up your workflow. Using Meteor's built-in content block helpers can further streamline your workflow by allowing nested and deferred template calls. In essence, you can combine and nest templates to create your own "components". This recipe will show you how to build a basic Spacebars custom block helper using Template.contentBlock
.
We will use the codebase from the Building a smooth interface with Bootstrap recipe found in this chapter. Please follow that recipe first, or download the corresponding codebase.
Proceed with the following steps to create custom components:
We need to make the template-specific
shapeCount
helper global so we can use it inside our component. Intemplates.js
, delete theshapeCount
function found in theTemplate.firstTemplate.helpers()
method call, and add the following function to the bottom of the page:Template.registerHelper('shapeCount',function (...