boxcars

boxcars is a tiny collection library that comes with built-in caching for preloading contents.

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(errortemplates){
  if(error) throw error;
 
  console.log( templates[0] ); // will put the content of templates/foo.html 
 
  // objects or arrays can be passed, as well 
  templates({ 'corge': 'templates/corge.html', 'eggs': 'templates/eggs.html' }, function(errormoreTemplates){
    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