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
- Host: GitHub
- URL: https://github.com/davemo/grunt-batman-templates
- Owner: davemo
- Created: 2013-09-28T13:27:13.000Z (over 12 years ago)
- Default Branch: main
- Last Pushed: 2021-11-20T01:13:34.000Z (over 4 years ago)
- Last Synced: 2025-04-04T12:07:56.575Z (about 1 year ago)
- Language: JavaScript
- Size: 11.7 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
grunt-batman-templates
======================
[](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
Batman.View.store.set('posts/show', '
Post:
\n\n\n');
Batman.View.store.set('posts/subfolder/subtemplate', '
This is a special template
\nBatman.View.store.set('products/index', '
Welcome to the Posts Page
\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.