# htmplate

> Create HTML templates using HTM

Latest version **0.1.0** (published 2022-12-15) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2022-12-15 |
| First published | 2022-12-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 6.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Eugene Ghanizadeh Khoub |
| Maintainers | lorean.victor |
| Keywords | HTM, template, HTML, DOM, HyperScript |

## Links

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

## Dependencies (2)

- [htm](https://npm.io/package/htm.md) ^3.1.1
- [vhtml](https://npm.io/package/vhtml.md) ^2.2.0

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 0.1.0 (latest) — 2022-12-15
- 0.0.1 — 2022-12-15

## README

[![tests](https://github.com/loreanvictor/htmplate/actions/workflows/test.yml/badge.svg)](https://github.com/loreanvictor/htmplate/actions/workflows/test.yml)
[![version](https://img.shields.io/npm/v/htmplate?logo=npm)](https://www.npmjs.com/package/htmplate)
![types](https://img.shields.io/npm/types/htmplate)
[![npm bundle size](https://img.shields.io/bundlephobia/minzip/htmplate?color=black&label=size)](https://bundlephobia.com/package/htmplate@latest)


Create [HTML templates](https://www.w3schools.com/tags/tag_template.asp) using [HTM (HyperScript Tagged Markup)](https://github.com/developit/htm).

```js
import { template, use } from 'htmplate'

const tmpl = template`
  <div class=container>
    <h1>Hellow World!</h1>
    <button>CLICK ME!</button>
  </div>
`

document.body.appendChild(use(tmpl))
```
[👉 Try it out!](https://codepen.io/lorean_victor/pen/vYroJwP)

<br>

## Installation

On [node](https://nodejs.org/en/):
```bash
npm i htmplate
```
In the browser:
```js
import { template, use } from 'https://esm.sh/htmplate'
```

<br>

## Usage

👉 Define [HTML templates](https://www.w3schools.com/tags/tag_template.asp) using a JSX-like syntax:

```js
const tmpl = template`<div>Hellow World!</div>`
```

The syntax is powered by [HTM](https://github.com/developit/htm), so you get bonuses such as self-closing tags (`<div/>`), components (`<${Foo}/>`), syntax-highlighting (e.g. [this VSCode plugin](https://marketplace.visualstudio.com/items?itemName=bierner.lit-html), though requires additional configuration), etc. See [HTM's docs](https://github.com/developit/htm) for more info.

👉 Use [HTM templates](https://www.w3schools.com/tags/tag_template.asp) (whether defined using `template` or not) to create elements:
```js
document.body.appendChild(use(tmpl))
```

<br>

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