engine-cache
express.js inspired template-engine manager.
Install
Install with npm
$ npm i engine-cache --save
Usage
var Engines = require('engine-cache');
API
Params
engines
{Object}: Optionally pass an object of engines to initialize with.
Example
var Engines = require('engine-cache');
var engines = new Engines();
Register the given view engine callback fn
as ext
.
Params
ext
{String}options
{Object|Function}: or callback fn
.fn
{Function}: Callback.returns
{Object} Engines
: to enable chaining.
Example
var consolidate = require('consolidate')
engines.setEngine('hbs', consolidate.handlebars)
Return the engine stored by ext
. If no ext
is passed, undefined is returned.
Params
ext
{String}: The engine to get.returns
{Object}: The specified engine.
Example
var consolidate = require('consolidate')
engine.setEngine('hbs', consolidate.handlebars);
engine.getEngine('hbs');
Load an object of engines onto the cache
. Mostly useful for testing, but exposed as a public method.
Params
obj
{Object}: Engines to load.returns
{Object} Engines
: to enable chaining.
Example
engines.load(require('consolidate'))
Get and set helpers for the given ext
(engine). If no ext
is passed, the entire helper cache is returned.
Example:
See helper-cachefor any related issues, API details, and documentation.
Params
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('bar', function() {});
helpers.getEngineHelper('bar');
helpers.getEngineHelper();
Related
- assemble: Static site generator for Grunt.js, Yeoman and Node.js. Used by Zurb Foundation, Zurb Ink, H5BP/Effeckt,… more | homepage
- async-helpers: Use async helpers in templates with engines that typically only handle sync helpers. Handlebars and… more | homepage
- engines: Template engine library with fast, synchronous rendering, based on consolidate. | homepage
- helper-cache: Easily register and get helper functions to be passed to any template engine or node.js… more | homepage
- templates: System for creating and managing template collections, and rendering templates with any node.js template engine.… more | homepage
Running tests
Install dev dependencies:
$ npm i -d && npm test
Changelog
v0.16.0 the .clear()
method was removed. A custom inspect
method was added.
v0.15.0 .getEngine()
no longer returns the entire cache
object when ext
is undefined.
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Author
Jon Schlinkert
License
Copyright © 2014-2015 Jon Schlinkert
Released under the MIT license.
This file was generated by verb-cli on September 20, 2015.