## JavaScript Template Compilation ##

* Contributed By: Tyler Kellen (@tkellen)

This build task compiles templates that can be concatenated and minified
with existing source files using any templating engine that supports
precompilation.

### Installation/Updating instructions

Download this folder into your `build/tasks` directory.  Remove any
existing `build/tasks/templatize` folders to avoid potential conflicts.

### Configuration

Inside your `build/config.js` file, add a section named `templatize` and specify
the compliation settings.  The `namespace` key is where the templates will be
stored.  The `method` key holds the compile function that will be called for each
template.  The `params` key contains any additional arguments to be sent with the
compilation function.  If the resulting template needs to be wrapped by some
initilization code, it can be defined as a function with the `wrapper` key.  A
semicolon will be inserted at the end of each template--none is needed in the
wrapper function.  The `library' key contains a path to any library that may be
required to support template precompliation.

``` javascript
templatize: {
  handlebars: {
    namespace: 'JST',
    method: require("handlebars").precompile,
    files: {
      "dist/debug/templates.js": [
        "app/templates/**/*.html"
       ]
    },
    wrapper: function(text) {
      return "(function() { "+text+" }.call(this);";
    }
  },

  hogan: {
    namespace: 'JST',
    method: require('hogan').compile,
    params: [{asString: true }],
    files: {
      "dist/debug/templates.js": [
        "app/templates/**/*.html"
       ]
    },
    library: 'app/js/libs/hogan/lib/template.js'
    wrapper: function(text) {
      return "new Hogan.Template("+text+")";
    }
  }
}
```
The above sample will precompile mustache templates using the Hogan library.
If you require a different templating engine, you must install it with npm in
the same directory as config.js (or globally).

### Usage ###

At the bottom of your `build/config.js` you will see `registerTask` containing
a list of build tasks to run, simply add templatize:hogan in this space-separated
list.

``` javascript
// An example registration might look something like this
task.registerTask("default", "clean ... templatize:hogan concat");
```