engine-cache
express inspired template-engine manager.
Install
Install with npm:
npm i engine-cache --save-dev
Usage
var engines = require('engine-cache');
API
engines
Create a new instance of Engines
, optionally passing the default options
to use.
options
{Object}: Default options to use.
Example:
var Engines = require('engine-cache')
var engines = new Engines()
.extend
Extend the options with the given obj
.
obj
{Object}- returns {Object}
engines
: to enable chaining.
engines.extend('a', true)
engines.extend('a')
.option
Set or get an option.
key
{String}value
{*}- returns {Object}
engines
: to enable chaining.
engines.option('a', true)
engines.option('a')
.register
Register the given view engine callback fn
as ext
.
ext
{String}fn
{Function|Object}: or options
options
{Object}- returns {Object}
engine
: to enable chaining
var consolidate = require('consolidate')
engines.register('hbs', consolidate.handlebars)
.load
Load an object of engines onto the cache
. Mostly useful for testing, but exposed as a public method.
engines
{Object}- returns {Object}
Engines
: to enable chaining.
engines.load(require('consolidate'))
.get
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')
.clear
Remove ext
from the cache, or if no value is specified the entire cache is reset.
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 09, 2014.