compiles any and all templates into ready to use includes


forked from grunt-template-client package

Compile any and all templates into a ready to use script include.

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

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


given the following config and template

  batman: {
    dist: {
        src: ['templates/**/*.html'],
        dest: 'dist/tmpl.js' 
<h1 data-bind="date"></h1>
<h2 data-bind="time"></h2>
<h1 class="title" data-bind="title"></h1>
<h2 class="value" data-bind="current | prettyNumber | prepend prefix"></h2>
<p class="more-info" data-bind="moreinfo"></p>

will output the following script file

(function bundleTemplates() {"graph", '<h1 class="title" data-bind="title"></h1><h2 class="value" data-bind="current | prettyNumber | prepend prefix"></h2><p class="more-info" data-bind="moreinfo"></p>' );"clock", '<h1 data-bind="date"></h1><h2 data-bind="time"></h2>' );

ready to use/include/concat etc.

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.

  • 0.2.1 - Forked to make it specific to Batman
  • 0.2.0 - Forked from to make generic.
  • 0.1.1 - Initial release

Copyright (c) 2012 Florian Traverse Licensed under the MIT license.