Book Image

Meteor Cookbook

By : Isaac Strack
Book Image

Meteor Cookbook

By: Isaac Strack

Overview of this book

Table of Contents (19 chapters)
Meteor Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating custom components


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.

Getting ready

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.

How to do it…

Proceed with the following steps to create custom components:

  1. We need to make the template-specific shapeCount helper global so we can use it inside our component. In templates.js, delete the shapeCount function found in the Template.firstTemplate.helpers() method call, and add the following function to the bottom of the page:

    Template.registerHelper('shapeCount',function (...