html-code-gen
html-code-gen is a HTML-code generator. It generates HTML code with given dom(-like) object.
Install
-
nodejs
npm install html-code-gen
var htmlCodeGen = require('html-code-gen'),
-
browser (UMD bundle generated by browserify)
-
global
<script src="html-code-gen/browser/html-code-gen.min.js"></script>
var htmlCodeGen = window.htmlCodeGen,
output = htmlCodeGen.print(dom, opt);
-
AMD
var htmlCodeGen = require('html-code-gen'),
output = htmlCodeGen.print(dom, opt);
Usage
var output = htmlCodeGen.print(dom, opt);
Options
-
indent-size
: size of indent
default: 4
-
indent-char
: char of indent ( space / tab )
default: 'space'
-
max-char
: max char num in one line (TODO)
default: 80
-
no-format-tag
: tags whose content should not be formatted
default: spec.tagTypeMap.inline
-
no-format
: no format
default: false
-
formatter
: special formatters { tagName ( script / style ) : formater )
default: {}
-
bool-attribute-value
: hide value of boolean attribute or not ( 'remove' / 'preserve' )
default: 'remove'
,
-
level
: current level
default: 0
Development
-
run test cases
npm run test
-
build for browser
npm run browser