JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 377
  • Score
    100M100P100Q89171F
  • License MIT

Generate HTML with node.js

Package Exports

  • html-creator

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (html-creator) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

html-creator

Generate HTML with NodeJS
Documentation ยป


Installation

npm install html-creator

Usage

var htmlCreator = require('html-creator');
var html = new htmlCreator([
    { type: 'head', content: [{ type: 'title', content: 'Generated HTML' }] },
    {
        type: 'body',
        attributes: { style: 'padding: 1rem' },
        content: [
            {
                type: 'div',
                content: [
                    {
                        type: 'span',
                        content: 'A Button Span Deluxe',
                        attributes: { className: 'button' },
                    },
                    {
                        type: 'a',
                        content: 'Click here',
                        attributes: { href: '/path-to-infinity', target: '_blank' },
                    },
                ],
            },
        ],
    },
]);

html.renderHTML();

This will result with the following:

<!DOCTYPE html>
<html>
    <head>
        <title>Generated HTML</title>
    </head>
    <body style="padding: 1rem">
        <div>
            <span class="button">A Button Span Deluxe</span>
            <a href="/path-to-infinity" target="_blank">Click here</a>
        </div>
    </body>
</html>

๐Ÿ“– Documentation

Visit the wiki for more examples of usage, method reference and further reading.

Contribute

Do you believe that something is missing from this plugin or perhaps is not working as intended? Awesome-pants! Help is always appreciated. Just be sure to read through the Contributing Handbook (and remember to have a jolly good time).