Skip to content

plus3network/grunt-hogan

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

grunt-hogan

a grunt task to compile/precompile hogan templates

Getting Started

Install this grunt plugin next to your project's grunt.js gruntfile with: npm install grunt-hogan --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.

About

a grunt.js plugin to compile/precompile hogan templates

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • JavaScript 100.0%