0.1.0 ā€¢ Published 1 year ago

htmplate v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

tests version types npm bundle size

Create HTML templates using HTM (HyperScript Tagged Markup).

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!

Installation

On node:

npm i htmplate

In the browser:

import { template, use } from 'https://esm.sh/htmplate'

Usage

šŸ‘‰ Define HTML templates using a JSX-like syntax:

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

The syntax is powered by HTM, so you get bonuses such as self-closing tags (<div/>), components (<${Foo}/>), syntax-highlighting (e.g. this VSCode plugin, though requires additional configuration), etc. See HTM's docs for more info.

šŸ‘‰ Use HTM templates (whether defined using template or not) to create elements:

document.body.appendChild(use(tmpl))