Skip to content

Node.js utility to build a single HTML file from multiple sources

License

Notifications You must be signed in to change notification settings

benderjs/dom-combiner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Node.js utility to build a single HTML file from multiple sources

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •