Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eldoy/htmlview
HTML view template string function
https://github.com/eldoy/htmlview
Last synced: 6 days ago
JSON representation
HTML view template string function
- Host: GitHub
- URL: https://github.com/eldoy/htmlview
- Owner: eldoy
- License: mit
- Created: 2022-02-23T08:20:41.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-06-19T11:10:04.000Z (over 1 year ago)
- Last Synced: 2024-10-13T10:52:32.744Z (about 1 month ago)
- Language: JavaScript
- Homepage:
- Size: 769 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# HTML View
HTML view template string function.
This is a convenience function for creating HTML with Javascript.
### Install
In the browser, grab one of the files from the `dist` folder in this repository.
```
npm i htmlview
```### Usage
```js
// For usage with NodeJS only
const h = require('htmlview')// HTML string, just like normal template string
const html = h`hello`
//hello// HTML string with variables, like normal
const html = h`hello ${5}`
//hello 5// Automatically joins array variables
const html = h`hello ${[ '1', '2', '3']}`
//hello 123// Avoid automatically joining array variables
const html = h`hello ${[ '1', '2', '3'].join(',')}`
//hello 1,2,3// Automatically calls functions
const html = h`hello ${() => 'bye'}`
//hello bye// Returns empty string by default, not 'undefined'
const html = h`hello${() => {`
if (project.done) return 'bye'
}}
//hello
```MIT Licensed. Enjoy!