Giter Club home page Giter Club logo

engine-cache's Introduction

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

Install with yarn:

$ yarn add engine-cache

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)

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'))

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]}

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

Related projects

  • 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

Commits Contributor
113 jonschlinkert
51 doowb

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

Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:

$ 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.5.0, on April 20, 2017.

engine-cache's People

Contributors

jonschlinkert avatar doowb avatar

Stargazers

Cat  avatar Mathieu M-Gosselin avatar Jerzerak avatar Charlike Mike Reagent avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

doowb

engine-cache's Issues

Compiled templates are being rendered twice.

When using an engine's .compile method, then calling the returned function is causing the template to be rendered twice.

I have a fix for this that I'll push up soon. I'm testing it with downstream modules.

custom inspect method

@doowb maybe we should create a custom inspect method for engines... they make it hard to inspect the app instance, since sometimes the engine object has the entire lodash or handlebars instance.

we could do something like <Engine "handlebars"> thoughts?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.