# htmlview

> HTML view template string function

Latest version **0.7.2** (published 2023-06-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install htmlview
pnpm add htmlview
yarn add htmlview
bun add htmlview
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.7.2 |
| Published | 2023-06-19 |
| First published | 2022-02-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Vidar Eldøy |
| Maintainers | eldoy |

## Links

- npm: https://www.npmjs.com/package/htmlview
- Repository: https://github.com/eldoy/htmlview
- Homepage: https://github.com/eldoy/htmlview#readme
- Issues: https://github.com/eldoy/htmlview/issues
- npm.io page: https://npm.io/package/htmlview

## Recent versions

- 0.7.2 (latest) — 2023-06-19
- 0.7.1 — 2023-06-19
- 0.7.0 — 2023-06-19
- 0.6.0 — 2023-06-19
- 0.5.3 — 2023-06-19
- 0.5.2 — 2023-06-19
- 0.5.1 — 2023-06-19
- 0.5.0 — 2023-06-19
- 0.4.1 — 2023-05-02
- 0.4.0 — 2023-05-02
- 0.3.0 — 2023-05-02
- 0.2.0 — 2022-02-23
- 0.1.1 — 2022-02-23
- 0.1.0 — 2022-02-23

## 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`<div>hello</div>`
// <div>hello</div>

// HTML string with variables, like normal
const html = h`<div>hello ${5}</div>`
// <div>hello 5</div>

// Automatically joins array variables
const html = h`<div>hello ${[ '1', '2', '3']}</div>`
// <div>hello 123</div>

// Avoid automatically joining array variables
const html = h`<div>hello ${[ '1', '2', '3'].join(',')}</div>`
// <div>hello 1,2,3</div>

// Automatically calls functions
const html = h`<div>hello ${() => 'bye'}</div>`
// <div>hello bye</div>

// Returns empty string by default, not 'undefined'
const html = h`<div>hello${() => {
  if (project.done) return '<b>bye</b>'
}}</div>`
// <div>hello</div>
```

MIT Licensed. Enjoy!

---
_Source: https://npm.io/package/htmlview · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
