Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including grunt-hogan-client with all npm packages installed. Try it out:

var gruntHoganClient = require("grunt-hogan-client")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

grunt-hogan-client v0.1.3

compiles hogan templates into ready to use includes


Compile Hogan Templates into ready to use script include.

Getting Started

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

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



given the following config and template


  hoganclient: {
    options: {
      variable: 'window.tmpl'
    src: ['templates/**/*.hogan'],
    dest: 'dist/tmpl.js' 





<ul id="a-list">

will output the following script file


window.tmpl.list=Hogan.compile('<ul id="a-list">{{#items}}{{>item}}{{/items}}</ul>');

ready to use/include/concat etc in your app like this.

tmpl.list.render({ items: [] });

Wrapping the templates.

I made this plugin for a very specific case where I also needed to wrap the templates in some code due to async loading of Hogan using head.js.

Since this task is a code generator I decided to add the wrap property to the options.


options: {
  wrap: {
    start: 'head.ready(function() {',
    end: '});'


I guess there will be need to tweek the regex that cleans the template.


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)


Copyright (c) 2012 Markus Ullmark
Licensed under the MIT license.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free