Cupboard is an extension to Flatiron Plates templating library. It will recurse through a folder creating an object tree which matches the directory layout. All html files will be loaded from disk, and plates map and bind function become available on the returned objects.
JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
test
.gitignore
.travis.yml
README.md
package.json

README.md

Cupboard

Build Status

Cupboard is a wrapper around Plates. It loads templates from disk and wraps them in an object with a map and bind function.

npm install plates-cupboard

Usage

To use Cupboard, tell it where to find your template folder.

var cupboard = require('cupboard');

var templates = cupboard('./templates');

Cupboard will recurse through the folder creating an object tree which matches the directory layout. All html files will be loaded from disk, and plates map and bind function become available on the returned objects.

For example, assuming the following directory structure:

	templates
		dashboard
			index.html

You'd be able to do this with Cupboard:

var templates = cupboard('./templates/'),
	data = { home: '/home' };

templates.dashboard.index.map.where('href').is('/').insert('home'); // call Plates' map functions
templates.dashboard.index.bind(data); // call Plates' bind function. templates.dashboard.index.map is passed in internally.

Notes

All file operations are performed synchronously. As such, it's best to use Cupboard when your app starts.