Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/dy/xhtm
- Owner: dy
- License: mit
- Created: 2019-11-22T16:24:15.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-12-29T02:54:10.000Z (10 months ago)
- Last Synced: 2024-10-26T12:20:46.168Z (10 days ago)
- Topics: htm, html, jsx, preact, tagged-template, virtual-dom
- Language: JavaScript
- Homepage:
- Size: 285 KB
- Stars: 25
- Watchers: 4
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# XHTM − eXtended HTM Tagged Markup
_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.🕉️