1.0.0 • Published 6 years ago
broccoli-dom-filter v1.0.0
Broccoli Dom Filter
Broccoli plugin for manipulating HTML with jsdom.
Usage
Add an Element in app/index.html:
const BroccoliDomFilter = require('broccoli-dom-filter');
const filter = new BroccoliDomFilter('app', {
files: ['index.html'],
processors: [(jsdom => {
const document = jsdom.window.document;
const head = document.querySelector('head');
const insertBefore = head.querySelector('title');
const meta = document.createElement('meta');
meta.setAttribute('name', 'test-name');
meta.setAttribute('content', 'test-content');
head.insertBefore(meta, insertBefore);
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".optionsfiles: The list of files to process the list of patterns against. This is an array of strings.processors: An array of callbacks that will processjsdomand 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 testLicense
This project is licensed under the MIT License.
1.0.0
6 years ago