boxcars

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

npm install boxcars
14 downloads in the last day
110 downloads in the last week
148 downloads in the last month

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] ); // 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(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
npm loves you