Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/cheton/html5-tag

A simple utility for creating HTML5 tags.
https://github.com/cheton/html5-tag

Last synced: 10 days ago
JSON representation

A simple utility for creating HTML5 tags.

Awesome Lists containing this project

README

        

# html5-tag [![build status](https://travis-ci.org/cheton/html5-tag.svg?branch=master)](https://travis-ci.org/cheton/html5-tag) [![Coverage Status](https://coveralls.io/repos/github/cheton/html5-tag/badge.svg?branch=master)](https://coveralls.io/github/cheton/html5-tag?branch=master)
[![NPM](https://nodei.co/npm/html5-tag.png?downloads=true&stars=true)](https://www.npmjs.com/package/html5-tag)

A simple utility for creating HTML5 tags.

## Installation

```bash
npm install --save html5-tag
```

## Usage
```js
import tag from 'html5-tag';

// No end tags for void elements (https://www.w3.org/TR/html5/syntax.html#void-elements)
tag('br');
// → '
'

tag('a', { href: 'http://example.com' }, 'Example');
// → 'Example'

tag('input', { name: 'name', value: 'Input your name...', disabled: true });
// → ''

tag('div', { title: '\'"&<>' }, tag('i', { class: 'icon icon-folder' }, ''));
// → '

'

// Defaults to 'div' if tag is not specified
tag({ class: 'container' }, 'container text');
// → '

container text
'
```

## License

Copyright (c) 2016 Cheton Wu

Licensed under the [MIT License](LICENSE).