dom-processor
Simple processor for replacing elements in html using cheerio.
Install
npm install dom-processor --save
Examples
dom-processor
Create a new instance using a config-loader and call the process
-method with the content to be processed.
If the loading of your replacement-configurations depends on the currently processed file make sure to call process
with the path as second argument.
var configLoader = ;var DomProcessor = ; var processor = configLoader; var result = processor; console;
config-loader
An object with a load
-method which is called with the path of the currently processed file and additional load configurations for cheerio.
The load
-method returns an Array
of replacement-configurations. Each replacement has two properties:
selector
: Selector of the elements to be replaced.replace
: Function to create and return the new element. It is called with matching element as first argument.
The loadConfigurations
-object cointains configurations for cheerio
{ return selector: 'div' { return '<span></span>'; } ;} let loadConfigurations = decodeEntities: false ; moduleexports = load: load loadConfigurations: loadConfigurations;
License
MIT © Benjamin Eckardt