Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
bin
tasks
test
.gitignore
.npmignore
LICENSE-MIT
README.md
grunt.js
package.json

README.md

grunt-batman-template

forked from grunt-template-client package

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

Getting Started

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:

grunt.loadNpmTasks('grunt-batman-template');

Example

given the following config and template

config

  batman: {
    dist: {
        src: ['templates/**/*.html'],
        dest: 'dist/tmpl.js' 
    }
  }

templates

templates/clock.html

<h1 data-bind="date"></h1>
<h2 data-bind="time"></h2>

templates/graph.html

<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

dist/tmpl.js

(function bundleTemplates() {
     Batman.View.store.set("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>' );
     Batman.View.store.set("clock", '<h1 data-bind="date"></h1><h2 data-bind="time"></h2>' );
}());

ready to use/include/concat etc.

Todo

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

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

License

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

Something went wrong with that request. Please try again.