grunt-hbt

> A sane Grunt plugin for compiling Handlebars templates to HTML files. Inspired by [grunt-contrib-handlebars](https://github.com/gruntjs/grunt-contrib-handlebars). These two grunt plugins may be used together to compile both static HTML and JST files from the same set of Handlebars templates.

npm install grunt-hbt
1 downloads in the last day
8 downloads in the last week
48 downloads in the last month

grunt-hbt Build Status

A sane Grunt plugin for compiling Handlebars templates to HTML files. Inspired by grunt-contrib-handlebars. These two grunt plugins may be used together to compile both static HTML and JST files from the same set of Handlebars templates.

Getting Started

This plugin requires Grunt ~0.4.0

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-hbt --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-hbt');

Handlebars task

Run this task with the grunt hbt command.

Task targets, files and options may be specified according to the grunt Configuring tasks guide.

Options

data

Type Object Default: {}

This option allows you to specify the data that will be used to render templates.

options: {
  data: grunt.file.readJSON('data.json')
}
`

helpers

Type: String Type: Array Type: Object

TODO: document this

options: {
  helpers: ''
}
`

partials

Type: String Type: Array Type: Object

TODO: document this

options: {
  helpers: ''
}
`

processPartialName

Type: function

This option accepts a function which takes one argument (the partial filepath) and returns a string which will be used as the key for the precompiled partial object when it is registered in Handlebars.partials. The example below stores all partials using only the actual filename instead of the full path.

options: {
  processPartialName: function(filePath) { // input:  templates/_header.hbs
    var pieces = filePath.split("/");
    return pieces[pieces.length - 1]; // output: _header.hbs
  }
}
`

Note: If processPartialName is not provided as an option the default assumes that partials will be stored by stripping trailing underscore characters and filename extensions. For example, the path templates/_header.hbs will become header and can be referenced in other templates as {{> header}}.

compilerOptions

Type Object Default: {}

This option allows you to specify a hash of options which will be passed directly to the Handlebars compiler.

options: {
  compilerOptions: {
    knownHelpers: {
      "my-helper": true,
      "another-helper": true
    },
    knownHelpersOnly: true
  }
}

Contributing

Make sure you've installed Node.js, which ships with npm.

# Install Grunt globally
$ npm install -g grunt-cli

# Clone the repository
$ git clone git://github.com/shannonmoeller/grunt-hbt
$ cd grunt-hbt

# Install the dependencies
$ npm install

# And grunt
$ grunt

Testing

$ grunt test

License

MIT

npm loves you