Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

This package has been deprecated

Author message:

WARNING: This project has been renamed to 'grunt-hb'. Install that instead.

grunt-hbt

0.1.3 • Public • Published

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');

hbt task

Run this task with the grunt hbt command.

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

Example

grunt.initConfig({
  hbt: {
    all: {
      options: {
        data: grunt.file.readJSON('src/meta.json'),
        helpers: 'src/view/helpers/*.js',
        partials: 'src/view/partials/*.hbt',
      },
 
      files: {
        'out/index.html': 'src/index.hbt'
      }
    }
  }

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

Bitdeli Badge

Keywords

none

install

npm i grunt-hbt

Downloadsweekly downloads

21

version

0.1.3

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability