Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/dy/xhtm

XHTM − eXtended Hyperscript Tagged Markup
https://github.com/dy/xhtm

htm html jsx preact tagged-template virtual-dom

Last synced: 9 days ago
JSON representation

XHTM − eXtended Hyperscript Tagged Markup

Awesome Lists containing this project

README

        

# XHTM − eXtended HTM Tagged Markup



size
version
stability

_XHTM_ is alternative implementation of [HTM](https://ghub.io/htm) without HTM-specific limitations.
Low-level machinery is rejected in favor of readability and better HTML support.

## Differences from HTM

* Self-closing tags support `` htm`
` `` → `[h('input'), h('br')]`.
* HTML directives ``, `` etc. support [#91](https://github.com/developit/htm/issues/91).
* Optionally closed tags support `

foo

bar` → `

foo

bar

` [#91](https://github.com/developit/htm/issues/91).
* Interpolated props are exposed as arrays `` html`` `` → `h('a', { class: ['a ', b, ' c'] })`.
* Calculated tag names [#109](https://github.com/developit/htm/issues/109) support.
* Ignoring null-like arguments (customizable) [#129](https://github.com/developit/htm/issues/129).
* Spaces formatting closer to HTML; elements with preserved formatting ([#23](https://github.com/dy/xhtm/issues/23)).
* No integrations exported, no babel compilers.
* No cache.

## Installation & Usage

[![NPM](https://nodei.co/npm/xhtm.png?mini=true)](https://nodei.co/npm/xhtm/)

`xhtm` is by default fully compatible with `htm` and can be used as drop-in replacement.

```js
import htm from 'xhtm'
import { render, h } from 'preact'

html = htm.bind(h)

render(html`

Hello World!


Some paragraph

Another paragraph
`, document.getElementById('app'))
```

For `htm` manual, refer to [htm docs](https://ghub.io/htm).

## Justification

Generally HTM is a better choice, since it has better performance and enables caching.

But if your app doesn't render components frequently or you need HTML support, then XHTM can be a good choice.
Originally that was just minimal HTML parser implementation (~60LOC), best from 10 variants in R&D branches.

🕉️