node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »



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


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:


You'd be able to do this with Cupboard:

var templates = cupboard('./templates/'),
    data = { home: '/home' };'href').is('/').insert('home'); // call Plates' map functions
templates.dashboard.index.bind(data); // call Plates' bind function, passing the map in as well.


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