Skip to content
This repository has been archived by the owner on Jul 16, 2021. It is now read-only.

7anshuai/html5-gen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

html5-gen Build Status

NPM

This project was created in order to generate HTML5 tags like lamernews HTMLGen class (ruby version), is free for everybody to use, fork, and have fun with.

Installation

NPM

$ npm install html5-gen

Bower

$ bower install html5-gen

Usage

Node.js

const HTMLGen = require('html5-gen');
const h5 = new HTMLGen();

h5.script({src: '/js/app.js'}); // <script src="/js/app.js"></script>
h5.script(); // <script></script>
h5.script('var h5;') // <script>var h5;</script>

// single tags
h5.meta({charset: 'utf8'}); // <meta charset="utf-8">

// short tags
h5.css() // <link rel="stylesheet">
h5.js() // <script></script>

// pass a anonymous function expression like ruby block
h5.div({class: 'container'}, () => {
  // do something and return html...
  return h5.span('Hello World!');
}); // <div class="container"><span>Hello World!</span></div>

Browser

<script src="bower_components/html5-gen/index.js"></script>
<script>
  const h5 = new HTMLGen();

  h5.script({src: '/js/app.js'}); // <script src="/js/app.js"></script>
  h5.script(); // <script></script>

</script>

With Require.js:

require(["bower_components/html5-gen/index"], function (HTMLGen){
  const h5 = new HTMLGen();

  h5.script({src: '/js/app.js'}); // <script src="/js/app.js"></script>
  h5.script(); // <script></script>
});

Testing

$ npm test

License

MIT