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

Wrapping Handlebars templates in AMD modules

In this recipe, we'll make use of the contrib-handlebars (0.8.0) plugin and its amd option to wrap our compiled blog template in an AMD module.

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 take us through altering our configuration so that it wraps our compiled templates in an AMD module.

  1. First, we'll alter the configuration by adding the amd option to indicate that the compiled templates should be wrapped in an AMD module:
    handlebars: {
      blog: {
        options: {
          amd: true }, src: 'blog.hbs', dest: 'templates.js' ...

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