Get unlimited public & private packages + team-based management with npm Teams.Learn more »

snapdragon-is-inside

0.1.2 • Public • Published

snapdragon-is-inside NPM version NPM monthly downloads NPM total downloads Linux Build Status

Snapdragon plugin that adds an isInside method to the compiler instance for checking if a node is currently inside a given node type.

Install

Install with npm:

$ npm install --save snapdragon-is-inside

Usage

The main export if a function that should be passed to snapdragon.use() to register the plugin.

Example

var Snapdragon = require('snapdragon');
var isInside = require('snapdragon-is-inside');
 
// register the plugin
var snapdragon = new Snapdragon();
snapdragon.use(isInside());
 
// or register directly on the compiler instance
var compiler = new Snapdragon.Compiler();
compiler.use(isInside());

.isInside

Returns true if node is currently inside the given node type(s).

Params

  • node {Object}
  • types {String|Array|Regex}: Pass one or more types to check for, or a regex to use for matching types.
  • returns {Boolean}: Returns true if the plugin

Example

snapdragon.use(isInside());
snapdragon.compiler
  .set('foo', function(node) {
    if (this.isInside(node, 'some-other-node-type')) {
      // do stuff
    }
  });

About

Related projects

Contributing

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

Please read the contributing guide for advice on opening issues, pull requests, and coding standards.

Building docs

(This document was generated by verb-generate-readme (a verb generator), please don't edit the readme directly. Any changes to the readme must be made in .verb.md.)

To generate the readme and API documentation with verb:

$ npm install -g verb verb-generate-readme && verb

Running tests

Install dev dependencies:

$ npm install -d && 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.1, on January 21, 2017.

Install

npm i snapdragon-is-inside

DownloadsWeekly Downloads

3

Version

0.1.2

License

MIT

Last publish

Collaborators

  • avatar