An open API service indexing awesome lists of open source software.

https://github.com/davemo/grunt-batman-templates

Generates and stores BatmanJS templates in the Batman HTMLStore
https://github.com/davemo/grunt-batman-templates

Last synced: about 1 year ago
JSON representation

Generates and stores BatmanJS templates in the Batman HTMLStore

Awesome Lists containing this project

README

          

grunt-batman-templates
======================

[![Build Status](https://travis-ci.org/davemo/grunt-batman-templates.png?branch=master)](https://travis-ci.org/davemo/grunt-batman-templates)

> Generates precache commands for Batman templates to pre-populate `Batman.View.store`

Getting Started
------------------

This plugin requires Grunt `~0.4.1`

If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

```shell
npm install grunt-batman-templates --save-dev
```

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

```js
grunt.loadNpmTasks('grunt-batman-templates');
```

The "batman_templates" task
---------------------------

### Overview
In your project's Gruntfile, add a section named `batman_templates` to the data object passed into `grunt.initConfig()`.

```js
grunt.initConfig({
batman_templates: {
options: {
templateFolder: 'app/html' // optional, defaults to 'app/html'
},
files: {
src: 'app/html/**/*.html'
dest: 'batman-view-precache.js'
}
}
});
```

Sample Output
---------------------------

The following shows what the resulting `batman-view-precache.js` file looks like, based on the unit tests:

```js
Batman.View.store.set('posts/index', '

Welcome to the Posts Page

\n
    \n
  • \n \n \n
  • \n
\n');
Batman.View.store.set('posts/show', '

Post:

\n\n
\n');
Batman.View.store.set('posts/subfolder/subtemplate', '

This is a special template

\n
Verifies that subfolder path lookups in the task work
\n');
Batman.View.store.set('products/index', '

Welcome to the Posts Page

\n
    \n
  • \n \n \n
  • \n
\n');
```

You would include this JavaScript file _after_ your Batman application code ie:

```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](http://gruntjs.com/).

License
------------

grunt-batman-templates was created by [David Mosher](http://www.github.com/davemo), and is distributed under the MIT license.