Originally inspired by an HTML helper in hexo by [Tommy Chen](https://github.com/tommy351). ## Usage ```js var tag = require('html-tag'); tag(name[, attribs, text]); ``` **Params** * `tag` **{String}**: Name of the tag to create. * `attribs` **{Object}**: Optional attributes * `text` **{String|Boolean}**: Optional text * `returns` **{String}**: string of HTML **Examples** ```js console.log(tag('a', {href: 'https://sellside.com'}, 'Sellside')); //=> Sellside console.log(tag('a', {id: 'anchor'})); //=> console.log(tag('strong', 'Let\'s dance!')); //=> Let's dance console.log(tag('div')); //=>
``` **Void elements (self-closing tags)** ```js console.log(tag('img', {src: 'foo.jpg'})); //=> console.log(tag('br')); //=>
console.log(tag('br', '\nfoo')); //=>
\nfoo ``` Force a tag to _not render_ the closing tag by passing boolean `false` as the last argument (this is sometimes necessary with XML implementations). ```js console.log(tag('P', 'Some random text...', false)); //=>

Some random text... console.log(tag('P', false)); //=>

``` **Boolean attributes** Boolean attributes are defined by defining the attribute with a boolean value (strictly `true` or strictly `false`) ```js console.log(tag('details', {open: true})); //=>

console.log(tag('details', {open: false})); //=>
console.log(tag('details', {open: 'false'})); //=>
```