component-builder-handlebars

Builder.js plugin to precompile Handlebars templates

npm install component-builder-handlebars
18 downloads in the last week
48 downloads in the last month

component-builder-handlebars

Builder.js plugin to precompile Handlebars templates to Component.js modules.

Usage

var handlebarsPlugin = require('component-builder-handlebars');

var builder = new Builder('test/fixtures');  
builder.use(handlebarsPlugin({
  extname: '.hbs',
  partialRegex: /^_/
}));

Or with grunt-component-build:

component: {
  app: {
    output: './build/',
    scripts: true,
    configure: function(builder) {
      builder.use(handlebarsPlugin({
        extname: '.hbs',
        partialRegex: /^_/
      }));
    }
  }
}

Options

extname

Type: String
Default value: .hbs
Define the Handlebars extension name.

partialRegex

Inspired from grunt-contrib-handlebars
Type: RegExp
Default value: /^_/
Define the prefix to identify Handlebars partials.

Example

[componentName/path/to/_navPartial.hbs]

<nav>
  <ul>
      <li>…</li>
      ...
  </ul>    
</nav>
[componentName/path/to/myTemplate.hbs]

<h1>{{title}}</h1>
<!-- When you include a partial don't use the prefix -->
{{> componentName/path/to/navPartial}}
[componentName/path/to/module.js]

var myTpl = require('./myTemplate');

var output = myTpl({
  title: 'Ready to start'
});

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.

License

Copyright (c) 2013 Antoine Lehurt
Licensed under the MIT license.

npm loves you