Skip to content

niklasvh/grunt-contrib-hogan

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

grunt-contrib-hogan

Build Status

Hogan template compiler task for grunt.

Getting Started

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

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

grunt.loadNpmTasks('grunt-contrib-hogan');

Overview

Grunt task that compiles Hogan templates into functions that can be loaded into the browser as is, or minified prior to loading. Configuration for this task is added to your grunt.js file with the hogan key.

Parameters

  • files object
    • This sets the files that will be processed, by destination: [source]
  • options object
    • This is the options that will be passed to the hogan task

Options

namespace string

The namespace that the templates will be assigned to, the default is Templates.

Example:

options: {
  namespace: 'T'
}

amdWrapper boolean

Wraps the compiled templates with the require.js define(function() {}) function.

Example:

options: {
  amdWrapper: true
}

Produces:

define(function() {
  this["Templates"] = this["Templates"] || {};

  return this["Templates"];
});

prettify boolean

Strip out spaces from the compiled templates, and make the output look a little better by indenting template definitions.

defaultName function

args:

  • filename

Function that returns the key that the template file will be assigned.

Example:

options: {
  defaultName: function(filename) {
    return filename.split('/').pop();
  }
}

templateOptions object

Any options that might need to be passed to the Hogan.compile() function.

Configuration example

hogan: {
      publish: {
        options: {
          prettify: true,
          templateName: function(file) {
            return file.toUppercase();
          }
        },
        files:{
          "path/to/compiled.js": ["path/to/source/**/*.html"]
        }
      }
    }

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

0.0.2 - No longer have to initialize a new Hogan.Template for every template you want to use.

0.0.1 - Initial release

License

Copyright (c) 2012 Matt McFarland Licensed under the MIT license.

About

Compile hogan templates with grunt.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%