create-html
Create the content of an html file with one function call.
Install
npm install --save create-html
Usage
createHTML(options)
options
title
script
scriptAsync
css
cssAsync
lang
dir
head
body
favicon
Examples
Simple example that create an html file with the title example
:
var html =
Example using all options:
var html =
Create a file with the html contents using the fs module:
var fs = var createHTML = var html = fs
Create a stream by pairing this module with from2-string
:
var fromString = var createHTML = var html = var stream = stream
Pipe content into the html that this module generates by using from2-string and hyperstream
var fs = var fromString = var hyperstream = var createHTML = var html = var hs = var stream = stream
Multiple CSS and Javascript Files
Multiple script and stylesheets can be added by sending an array instead of a string:
var html =
CLI
This module comes with a simple command-line tool for creating html files.
Install it globally with npm i -g create-html
Usage:
Usage:
create-html [options]
Options:
--title, -t Page title
--script, -s JavaScript filename, optional
--script-async, -a Add async attribute to script tag
--css, -c CSS filename, optional
--favicon, -f Site favicon
--lang, -l Language of content
--dir, -d Direction of content
--head, -H Content to insert into <head> tag
--body, -b Content to insert into <body> tag
--output, -o File name. optional. default: stdout
--help, -h Show this help message
Example:
create-html --title "an example html file"