This package has been deprecated

Author message:

end of development

html-divide

0.1.2 • Public • Published

HTML divide

npm version

HTML divide to object by comment block.

Install

npm i html-divide

Usage

For example, Create index.html such as the following

<p>content1</p>

<!-- divide:head -->
<p>head</p>
<!-- enddivide -->

<!-- divide:body -->
<p>body</p>
<!-- enddivide -->

<p>content2</p>

Use this way

'use strict';

const divide = require('html-divide'),
  fs = require('fs');

fs.readFile('path/to/index.html', 'utf-8', (err, content) => {
  const data = divide(content);
  console.log(data);  // output
});

Output

{ head: '<p>head</p>',
  body: '<p>body</p>',
  content: '<p>content1</p>\n<p>content2</p>' }

Change log

  • 0.1.2
    Fix set null in content when /^[\n\s]*$/
  • 0.1.1
    Add content property that collection of non-comment block
  • 0.1.0
    Not included fs.readFile

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i html-divide

      Weekly Downloads

      1

      Version

      0.1.2

      License

      MIT

      Last publish

      Collaborators

      • nju33