Template Plugin

Introduction

The template plugin provides allows for bundling of handlebars templates with the dependent javascript code, allowing templates to be kept in separate files and removing any need for additional requests to load the templates required by a given module.

Usage

The template plugin looks for a template configuration object defined on the root lumbar config. This object should be a hash of javascript pathnames whose values are arrays of template files. on build, each module that includes a file listed in this hash will have the associated templates defined at least once in the output.

Configuration

Example

{
  "modules": {
    "base": [
      {"src": "js/base.js"}
    ]
  },
  "templates": {
    "js/base.js": [
      "templates/home.handlebars",
      "templates/footer.handlebars"
    ],

    "precompile": {
      "knownHelpers": [
        "template",
        "view"
      ],
      "knownHelpersOnly": true
    }
  },

  "templateCache": "TemplateCache",
  "templateTemplate": "{{{templateCache}}}['{{{name}}}'] = Handlebars.compile('{{{data}}}');",
  "precompiledTemplate": "{{{templateCache}}}['{{{name}}}'] = Handlebars.template({{{data}}});"
}
Fork me on GitHub