Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

engine-cache

Package Overview
Dependencies
Maintainers
2
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

engine-cache

express.js inspired template-engine manager.

  • 0.19.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
33K
increased by18.15%
Maintainers
2
Weekly downloads
 
Created
Source

engine-cache NPM version NPM monthly downloads NPM total downloads Linux Build Status Windows Build Status

express.js inspired template-engine manager.

Install

Install with npm:

$ npm install --save engine-cache

Usage

var Engines = require('engine-cache');

API

Engines

Params

  • engines {Object}: Optionally pass an object of engines to initialize with.

Example

var Engines = require('engine-cache');
var engines = new Engines();

.setEngine

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)

.setEngines

Add an object of engines onto engines.cache.

Params

  • obj {Object}: Engines to load.
  • returns {Object} Engines: to enable chaining.

Example

engines.setEngines(require('consolidate'))

.getEngine

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');
var engine = engine.setEngine('hbs', consolidate.handlebars);

var engine = engine.getEngine('hbs');
console.log(engine);
// => {render: [function], renderFile: [function]}

.helpers

Get and set helpers for the given ext (engine). If no ext is passed, the entire helper cache is returned.

Example:

See helper-cache for 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();

Changelog

v0.19.0 ensure the string is only rendered once by passing the compiled function to the render method

v0.18.0 the .load method was renamed to .setHelpers

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.

About

  • assemble: Get the rocks out of your socks! Assemble makes you fast at creating web projects… 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

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Contributors

CommitsContributor
113jonschlinkert
48doowb

Building docs

(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)

To generate the readme, run the following command:

$ npm install -g verbose/verb#dev verb-generate-readme && verb

Running tests

Install dev dependencies:

$ npm install && npm test

Author

Jon Schlinkert

License

Copyright © 2017, Jon Schlinkert. Released under the MIT license.


This file was generated by verb-generate-readme, v0.4.2, on February 21, 2017.

Keywords

FAQs

Package last updated on 21 Feb 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc