https://github.com/doodzik/javascript-html-tags
create html programmatically with javascript
https://github.com/doodzik/javascript-html-tags
Last synced: over 1 year ago
JSON representation
create html programmatically with javascript
- Host: GitHub
- URL: https://github.com/doodzik/javascript-html-tags
- Owner: doodzik
- License: mit
- Created: 2016-10-30T10:15:57.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-10-23T09:26:42.000Z (almost 9 years ago)
- Last Synced: 2025-02-03T14:32:09.671Z (over 1 year ago)
- Language: JavaScript
- Size: 38.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# JavaScript HTML Tags
Create valid HTML with ease. Each HTML tag is a function with the same interface.
## Installation
```
npm i javascript-html-tags --save
```
## Usage
```
const {html, head, style, body, div, ...tags} = require('javascript-html-tags')
const cssRules = '.red{color:red}'
html(head(style(cssRules)),
body(div({class: 'red'}, 'hello'),
div('world!')))
```
## API
All arguments are concatenated. If the first one is an Object it will be interpreted as the html tags keys and values.
The ones with defaults are:
* style -> defaults to css
* script -> defaults to js
None tags are:
* xid -> returns a concatenated string of the arguments
If you find a tag that isn't supported open an issue
## LICENSE
MIT