Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
93 lines (72 sloc) 2.49 KB


a grunt task to compile/precompile hogan templates


Alpha, unpublished to npm. TODO:

  • generate default binder template
  • fill in tests
  • investigate desired binder template styles (APM, requireJS, vanilla, browser?)

Getting Started

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

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


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

    hogan: {
        //desired target name
        mytarget : {
            //indicate you want to compile templates
            compile : {
                //Wildcard of desired templates
                templates : "view/**/*.hogan",
                //output destination
                output : "hulkingup.js"

By default, the templates will be "bound" by the default "binder" (which is itself a pre-compiled template). The "default" template 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:

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

There can be multiple template patterns:

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


(Coming soon)


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

(Nothing yet)


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


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