Giter VIP home page Giter VIP logo

html-code-gen's Introduction

html-code-gen

Build Status NPM version Coverage Status Dependencies DevDependencies

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;
    • AMD

       var htmlCodeGen = require('html-code-gen');

Usage

htmlCodeGen.print(dom, opt);
htmlCodeGen.printAsync(dom, opt).then(
	output => console.log(output)
);

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.structural

  • no-format: no format

    default: false

  • inline-tag: tags whose content should be inline

    default: spec.tagTypeMap.inline

  • formatter: special formatters { tagName ( script / style ) : formater )

    default: {}

  • bool-attribute-value: hide value of boolean attribute or not ( 'remove' / 'preserve' )

    default: 'remove'

  • self-close: should void tags close themeselves with "/" ( 'close' / 'no-close' )

    default: 'no-close'

  • level: current level

    default: 0

Development

  • run test cases

      npm run test
    
  • build for browser

      npm run browser
    

html-code-gen's People

Contributors

chriswong avatar nighca avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

nighca lonjoy xsls

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.