aster-squery
Replace nodes with CSS-like selectors in aster.
Allows to use CSS-style selectors for finding nodes and replacing them with results of corresponding handlers.
Uses grasp-squery behind the scenes, so check out official documentation for syntax details.
Usage
First, install aster-squery
as a development dependency:
npm install --save-dev aster-squery
Then, add it to your build script:
var aster = ;var squery = ; aster;
can be also written as:
var aster = ;var equery = ; aster;
API
squery(mappings)
mappings
Type: {pattern: handler}
Replacement mappings.
pattern
Type: String
handler (option 1: callback)
Type: Function(node, named)
Callback to be called on each found match. It will get two arguments - matched node object and hashmap of named subpatterns.
handler (option 2: template)
Type: String
estemplate string to be used for generating AST.