Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/here-be/snapdragon-is-inside

Snapdragon plugin that adds an `isInside` method to the compiler instance for checking if a node is currently inside a given node type.
https://github.com/here-be/snapdragon-is-inside

ast compiler javascript node nodejs parser snapdragon snapdragon-plugin

Last synced: about 2 months ago
JSON representation

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

Awesome Lists containing this project

README

        

# snapdragon-is-inside [![NPM version](https://img.shields.io/npm/v/snapdragon-is-inside.svg?style=flat)](https://www.npmjs.com/package/snapdragon-is-inside) [![NPM monthly downloads](https://img.shields.io/npm/dm/snapdragon-is-inside.svg?style=flat)](https://npmjs.org/package/snapdragon-is-inside) [![NPM total downloads](https://img.shields.io/npm/dt/snapdragon-is-inside.svg?style=flat)](https://npmjs.org/package/snapdragon-is-inside) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/snapdragon-is-inside.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/snapdragon-is-inside)

> 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](https://www.npmjs.com/):

```sh
$ 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**

```js
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](index.js#L55)

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**

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

## About

### Related projects

* [snapdragon-capture](https://www.npmjs.com/package/snapdragon-capture): Snapdragon plugin that adds a capture method to the parser instance. | [homepage](https://github.com/jonschlinkert/snapdragon-capture "Snapdragon plugin that adds a capture method to the parser instance.")
* [snapdragon-node](https://www.npmjs.com/package/snapdragon-node): Snapdragon utility for creating a new AST node in custom code, such as plugins. | [homepage](https://github.com/jonschlinkert/snapdragon-node "Snapdragon utility for creating a new AST node in custom code, such as plugins.")
* [snapdragon-position](https://www.npmjs.com/package/snapdragon-position): Snapdragon util and plugin for patching the position on an AST node. | [homepage](https://github.com/jonschlinkert/snapdragon-position "Snapdragon util and plugin for patching the position on an AST node.")
* [snapdragon-util](https://www.npmjs.com/package/snapdragon-util): Utilities for the snapdragon parser/compiler. | [homepage](https://github.com/jonschlinkert/snapdragon-util "Utilities for the snapdragon parser/compiler.")
* [snapdragon](https://www.npmjs.com/package/snapdragon): Fast, pluggable and easy-to-use parser-renderer factory. | [homepage](https://github.com/jonschlinkert/snapdragon "Fast, pluggable and easy-to-use parser-renderer factory.")

### Contributing

Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).

Please read the [contributing guide](.github/contributing.md) for advice on opening issues, pull requests, and coding standards.

### Building docs

_(This document was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme) (a [verb](https://github.com/verbose/verb) generator), please don't edit the readme directly. Any changes to the readme must be made in [.verb.md](.verb.md).)_

To generate the readme and API documentation with [verb](https://github.com/verbose/verb):

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

### Running tests

Install dev dependencies:

```sh
$ npm install -d && npm test
```

### Author

**Jon Schlinkert**

* [github/jonschlinkert](https://github.com/jonschlinkert)
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)

### License

Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT license](LICENSE).

***

_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.4.1, on January 21, 2017._