Broccoli Dom Filter
Broccoli plugin for manipulating HTML with jsdom.
Usage
Add an Element in app/index.html
:
const BroccoliDomFilter = ; const filter = 'app' files: 'index.html' processors: { const document = jsdomwindowdocument; const head = document; const insertBefore = head; const meta = document; meta; meta; head; return jsdom; };
Documentation
new BroccoliDomFilter(inputNodes, options)
BroccoliDomFilter is a subclass of BroccoliPersistentFilter which has additional options available in the constructor. Please see BroccoliPersistentFilter Options for documentation.
inputNodes
: An array of node objects that this plugin will read from. Nodes are usually other plugin instances; they were formerly known as "trees".options
files
: The list of files to process the list of patterns against. This is an array of strings.processors
: An array of callbacks that will processjsdom
and returnjsdom
.processorOptions
: A context that can will be passed as the second argument to a processor.
function processor(jsdom, processorOptions = {})
Processors allow you to modify the document currently being processed by jsdom
. A processor
MUST take the jsdom
argument and MUST return the jsdom
argument. If you created an
instance of BroccoliDomFilter
with processorOptions
, that is provided to your processor as
the second argument, otherwise it will default to {}
.
Tests
npm install
npm test
License
This project is licensed under the MIT License.