Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/marceljs/acorn-sontag

Acorn plugin to parse Sontag expressions
https://github.com/marceljs/acorn-sontag

Last synced: 8 days ago
JSON representation

Acorn plugin to parse Sontag expressions

Awesome Lists containing this project

README

        

# acorn-sontag

An Acorn-based parser for [Sontag](https://github.com/marceljs/sontag) expressions.

## Installation

```bash
# using npm
npm install acorn-sontag

# using yarn
yarn add acorn-sontag
```

## Usage

```js
let { expression } = require('acorn-sontag');

let result = expression('posts[posts.length - 1] | escape', {
// The scope to add to filters
filterScope: 'this.__filters__',

// The scope to add to other identifiers
identifierScope: 'this',

// The name of the range function to call
// for the `..` range operator
rangeFunction: 'this.__filters__.range',
});

console.log(result);
// => this.__filters__.escape(this.posts[this.posts.length - 1])
```