Skip to content
This repository has been archived by the owner on Aug 23, 2019. It is now read-only.

A sane Grunt plugin for compiling Handlebars templates to HTML files. **Unmaintained**

Notifications You must be signed in to change notification settings

shannonmoeller-archive/grunt-hbt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DEPRECATED: Use grunt-hb instead.

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

About

A sane Grunt plugin for compiling Handlebars templates to HTML files. **Unmaintained**

Resources

Stars

Watchers

Forks

Packages

No packages published