boxcars is a tiny collection library that comes with built-in caching for preloading contents.
Install
$ npm install boxcars
Usage
var boxcars = require('boxcars'),
mustache = require('mustache');
var templates = boxcars();
templates('templates/foo.html', 'templates/bar.html', 'templates/quux.html', function(error, templates){
if(error) throw error;
console.log( templates[0] );
templates({ 'corge': 'templates/corge.html', 'eggs': 'templates/eggs.html' }, function(error, moreTemplates){
if(error) throw error;
console.log( moreTemplates.corge );
});
});
Preloading:
templates.cache({
'quux.json': '{}',
'templates/foo.html': '<strong>Hello {{ name }}!</strong>',
'templates/bar.html': '<strong>Hello {{ name }}!</strong>'
});
Reset the cache:
templates.cache(undefined);
Testing
Publish the tests and visit localhost:1314 with the browser you want to test.
$ make publish-tests
To see the summary of the results;
$ make verify-tests