Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: grunt-0.3
Fetching contributors…

Cannot retrieve contributors at this time

98 lines (78 sloc) 3.266 kB

grunt-hogan (for grunt 0.3.x)

a grunt task to compile/precompile hogan templates. These instructions are specific to the 0.3.x version of grunt. For a version that supports the latest grunt code, see the master branch.

Getting Started

Install this grunt plugin next to your project's grunt.js gruntfile with: npm install grunt-hogan@grunt-0.3 --save-dev

Then add this line to your project's grunt.js gruntfile:

grunt.loadNpmTasks('grunt-hogan');

To compile multiple mustache templates to a single output file, your config should look like this:

grunt.initConfig({
    //...
    hogan: {
        //desired target name
        mytarget : {
          //Wildcard of desired templates
          templates : "view/**/*.hogan",
          //output destination
          output : "hulkingup.js"
        }
    },
    //...
});

By default, the all compiled templates in a target will be "bound" together by the default "binder" (which is itself a pre-compiled template). The "default" binder generates javascript that is designed to work both as a node.js module and in the browser via a <script/> tag. Also supported are the "hulk" binder (should output similarly to hogan's "hulk" command line tool...which is "vanilla" javascript), and the "nodejs" binder, which provides a pure node.js format. You can also create your own binder templates to support other usages.

To specify a binder, use a "binderName" directive:

//...
mytarget : {
    templates : "view/**/*.hogan",
    output : "hulkingup.js",
    binderName : "hulk"
}
//...

To specify a custom binder, supply a path for the "binder" attribute that resolves to a binder module:

//...
binder : __dirname + "/my/custom/binder.js"
//...

See the *custombinder* targets in the example gruntfile for futher detail on creating and using custom binders.

There can be multiple template patterns:

//...
mytarget : {
    //...
    templates : ["view/wwf/*.hogan", "view/wcw/*.hogan"],
    //...
}
//...

Documentation

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 using grunt.

Release History

Acknowledgements

  • a comment by "baz" here pointed me in the right direction

License

Copyright (c) 2013 Elliott B. Edwards
Licensed under the MIT license.

Jump to Line
Something went wrong with that request. Please try again.