Socket
Book a DemoInstallSign in
Socket

parser-cache

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parser-cache

Cache and load parsers, similiar to consolidate.js engines.

Source
npmnpm
Version
0.2.0
Version published
Weekly downloads
118
145.83%
Maintainers
1
Weekly downloads
 
Created
Source

parser-cache NPM version

express.js inspired template-parser manager.

Install

Install with npm

npm i parser-cache --save

Usage

var parsers = require('parser-cache');

API

parsers

Create a new instance of Engines, optionally passing the default options to use.

  • options {Object}: Default options to use.

Example:

var Engines = require('parser-cache')
var parsers = new Engines()

.register

Register the given view parser callback fn as ext.

  • ext {String}
  • fn {Function|Object}: or options
  • options {Object}
  • returns {parsers}: to enable chaining.
var consolidate = require('consolidate')
parsers.register('hbs', consolidate.handlebars)

.load

Load an object of parsers onto the cache. Mostly useful for testing, but exposed as a public method.

  • obj {Object}: Engines to load.
  • returns {parsers}: to enable chaining.
parsers.load(require('consolidate'))

.get

Return the parser stored by ext. If no ext is passed, the entire cache is returned.

  • ext {String}: The parser to get.
  • returns {Object}: The specified parser.
var consolidate = require('consolidate')
parser.set('hbs', consolidate.handlebars)
parser.get('hbs')
// => {render: [function], renderFile: [function]}

.clear

Remove ext from the cache, or if no value is specified the entire cache is reset.

Example:

parsers.clear()

.option

Set or get an option.

  • key {String}
  • value {*}
  • returns {parsers}: to enable chaining.
parsers.option('a', true)
parsers.option('a')
// => true

.extend

Extend the options with the given obj.

  • obj {Object}
  • returns {parsers}: to enable chaining.
parsers.extend({a: 'b'})
parsers.option('a')
// => 'b'

Author

Jon Schlinkert

License

Copyright (c) 2014 Jon Schlinkert, contributors. Released under the MIT license

This file was generated by verb-cli on August 10, 2014.

Keywords

assemble

FAQs

Package last updated on 27 Aug 2014

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