engine-cache
express.js inspired template-engine manager.
Install
Install with npm
npm i engine-cache --save
Usage
var engines = require('engine-cache');
API
options
{Object}: Default options to use.
var Engines = require('engine-cache');
var engines = new Engines();
Register the given view engine callback fn
as ext
.
ext
{String}options
{Object|Function}: or callback fn
.fn
{Function}: Callback.returns
{Object} Engines
: to enable chaining.
var consolidate = require('consolidate')
engines.register('hbs', consolidate.handlebars)
Wrap an engine to extend the helpers object and other native methods or functionality.
engine
{Object}: The engine to wrap.returns
{Object} engine
: The wrapped engine.
engines.wrapEngine(engine);
Load an object of engines onto the cache
. Mostly useful for testing, but exposed as a public method.
obj
{Object}: Engines to load.returns
{Object} Engines
: to enable chaining.
engines.load(require('consolidate'))
Return the engine stored by ext
. If no ext
is passed, the entire cache is returned.
ext
{String}: The engine to get.returns
{Object}: The specified engine.
var consolidate = require('consolidate')
engine.set('hbs', consolidate.handlebars)
engine.get('hbs')
Get and set helpers for the given ext
(engine). If no ext
is passed, the entire helper cache is returned.
ext
{String}: The helper cache to get and set to.returns
{Object}: Object of helpers for the specified engine.
Example:
var helpers = engines.helpers('hbs');
helpers.addHelper('foo', function() {});
helpers.getHelper('foo');
helpers.getHelper();
See helper-cache for any related issues, API details, and documentation.
Remove ext
engine from the cache, or if no value is specified the entire cache is reset.
ext
{String}: The engine to remove.
Example:
engines.clear()
Author
Jon Schlinkert
License
Copyright (c) 2014 Jon Schlinkert, contributors.
Released under the MIT license
This file was generated by verb-cli on August 29, 2014.