dom-combiner

0.1.3 • Public • Published

Build Status

dom-combiner

Node.js utility that builds a single page from two or more sources by merging documents and documentFragments created with parse5 into a single object. Subsequent sources overwrites or extends previous sources.

Default behaviours:

  • Overwrite <!doctype> declaration
  • Overwrite <title>'s content
  • Overwrite <meta> tags' values
  • Append new attributes to unique elements
  • Overwrite existing attributes of unique
  • Append new elements in <head> and <body> sections to their equivalents
  • If the elements are not wrapped in <html>/<head>/<body> append them to the <body> element of the previous source
  • Treat contents of <script>, <style>, <textarea> elements as a plain text

Installation

npm install dom-combiner

Usage

combine(html_1, html_2, [..., html_n], [callback]);

Example

var combine = require('dom-combiner'),
    template = '<!doctype html><html><head><title>Foo</title></head><body></body></html>',
    html = '<body class="foo"><div id="baz">Baz</div></body>';
 
var output = combine(template, html);
// <!doctype html><html><head><title>Foo</title></head><body class="foo"><div id="baz">Baz</div></body></html>

Testing

npm test

License

MIT, for license details see: LICENSE.md.

Readme

Keywords

none

Package Sidebar

Install

npm i dom-combiner

Weekly Downloads

2,229

Version

0.1.3

License

MIT

Unpacked Size

17.6 kB

Total Files

27

Last publish

Collaborators

  • cksource