Skip to content
Acorn plugin to parse Sontag expressions
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
README.md
index.js
index.test.js
package.json
yarn.lock

README.md

acorn-sontag

An Acorn-based parser for Sontag expressions.

Installation

# using npm
npm install acorn-sontag

# using yarn
yarn add acorn-sontag

Usage

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])
You can’t perform that action at this time.