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

Altering Handlebars templates before compilation

Although not very common, there might come a time that you would want to alter the contents of a template before compiling or rendering it. This is most commonly required when you would like to remove excessive whitespace from templates, or if you'd like to remove or replace certain parts of a template you have no control over.

In this recipe, we'll make use of the contrib-handlebars (0.8.0) plugin and the processContent option provided by its handlebars task to remove whitespace from our templates before compiling them.

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 ...

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