O'Reilly logo

Grunt Cookbook by Jurie-Jan Botha

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using partials in Handlebars templates

The partials system provided by the Handlebars templating engine allows us to reuse smaller bits of template code in varying contexts. Whenever you see a pattern repeated at different points in your template, it's probably a good opportunity to make use of a partial.

In this recipe, we'll make use of the contrib-handlebars (0.8.0) plugin and its partial template loading functionality to render posts with a similar structure in two different sections of a blog.

Getting ready

In this example, we'll work with the basic project structure we created in the Compiling Handlebars templates recipe of this chapter. Be sure to refer to it if you are not yet familiar with its contents.

How to do it...

The following steps ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required