All Projects → developit → Vhtml

developit / Vhtml

Licence: mit
Render JSX/Hyperscript to HTML strings, without VDOM 🌈

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Vhtml

Omi
Front End Cross-Frameworks Framework - 前端跨框架跨平台框架
Stars: ✭ 12,153 (+2085.79%)
Mutual labels:  virtual-dom, vdom, jsx, preact
Preact
⚛️ Fast 3kB React alternative with the same modern API. Components & Virtual DOM.
Stars: ✭ 30,527 (+5390.47%)
Mutual labels:  virtual-dom, vdom, jsx, preact
Muve
Muve is a micro library for building interactive javascript applications.
Stars: ✭ 11 (-98.02%)
Mutual labels:  virtual-dom, vdom, jsx
Ng Vdom
(Developer Preview) A virtual-DOM extension for Angular, also work as React bridge.
Stars: ✭ 249 (-55.22%)
Mutual labels:  virtual-dom, vdom, jsx
Preact Render Spy
Render preact components with access to the produced virtual dom for testing.
Stars: ✭ 178 (-67.99%)
Mutual labels:  vdom, jsx, preact
Redux React Starter
DEPRECATED use the new https://github.com/didierfranc/react-webpack-4
Stars: ✭ 137 (-75.36%)
Mutual labels:  virtual-dom, jsx, preact
Nerv
A blazing fast React alternative, compatible with IE8 and React 16.
Stars: ✭ 5,409 (+872.84%)
Mutual labels:  vdom, jsx, preact
Wonders
🌈 Declarative JavaScript framework to build command-line applications.
Stars: ✭ 34 (-93.88%)
Mutual labels:  virtual-dom, vdom, jsx
Virtual Dom
关于Vue,React,Preact和Omi等框架源码的解读
Stars: ✭ 139 (-75%)
Mutual labels:  virtual-dom, jsx, preact
Val
VirtualDOM abstraction layer - give yourself better integration and full control over the DOM with any virtual DOM library that uses a Hyperscript-like API such as React and Preact.
Stars: ✭ 181 (-67.45%)
Mutual labels:  virtual-dom, vdom, preact
tung
A javascript library for rendering html
Stars: ✭ 29 (-94.78%)
Mutual labels:  virtual-dom, jsx
core
Server side rendering with The Elm Architecture in Deno
Stars: ✭ 16 (-97.12%)
Mutual labels:  virtual-dom, jsx
snap-state
State management in a snap 👌
Stars: ✭ 23 (-95.86%)
Mutual labels:  preact, jsx
Ijk
Transforms arrays into virtual dom trees; a terse alternative to JSX and h
Stars: ✭ 452 (-18.71%)
Mutual labels:  vdom, preact
joltik
A really small VDOM library
Stars: ✭ 40 (-92.81%)
Mutual labels:  jsx, vdom
Gccx
Transforms CPX (JSX like syntax) into asm-dom Virtual DOM
Stars: ✭ 234 (-57.91%)
Mutual labels:  virtual-dom, jsx
react-lite
A simple implementation of react
Stars: ✭ 51 (-90.83%)
Mutual labels:  virtual-dom, jsx
Hyperawesome
A curated list of awesome projects built with Hyperapp & more.
Stars: ✭ 446 (-19.78%)
Mutual labels:  vdom, jsx
Asm Dom
A minimal WebAssembly virtual DOM to build C++ SPA (Single page applications)
Stars: ✭ 2,604 (+368.35%)
Mutual labels:  virtual-dom, vdom
vdom
Simple JavaScript Virtual DOM
Stars: ✭ 17 (-96.94%)
Mutual labels:  virtual-dom, vdom

vhtml

NPM travis-ci

Render JSX/Hyperscript to HTML strings, without VDOM

Need to use HTML strings (angular?) but want to use JSX? vhtml's got your back.

Building components? do yourself a favor and use Preact

JSFiddle Demo


Installation

Via npm:

npm install --save vhtml


Usage

// import the library:
import h from 'vhtml';

// tell babel to transpile JSX to h() calls:
/** @jsx h */

// now render JSX to an HTML string!
let items = ['one', 'two', 'three'];

document.body.innerHTML = (
  <div class="foo">
    <h1>Hi!</h1>
    <p>Here is a list of {items.length} items:</p>
    <ul>
      { items.map( item => (
        <li>{ item }</li>
      )) }
    </ul>
  </div>
);

New: "Sortof" Components!

vhtml intentionally does not transform JSX to a Virtual DOM, instead serializing it directly to HTML. However, it's still possible to make use of basic Pure Functional Components as a sort of "template partial".

When vhtml is given a Function as the JSX tag name, it will invoke that function and pass it { children, ...props }. This is the same signature as a Pure Functional Component in react/preact, except children is an Array of already-serialized HTML strings.

This actually means it's possible to build compositional template modifiers with these simple Components, or even higher-order components.

Here's a more complex version of the previous example that uses a component to encapsulate iteration items:

let items = ['one', 'two'];

const Item = ({ item, index, children }) => (
  <li id={index}>
    <h4>{item}</h4>
    {children}
  </li>
);

console.log(
  <div class="foo">
    <h1>Hi!</h1>
    <ul>
      { items.map( (item, index) => (
        <Item {...{ item, index }}>
          This is item {item}!
        </Item>
      )) }
    </ul>
  </div>
);

The above outputs the following HTML:

<div class="foo">
  <h1>Hi!</h1>
  <ul>
    <li id="0">
      <h4>one</h4>This is item one!
    </li>
    <li id="1">
      <h4>two</h4>This is item two!
    </li>
  </ul>
</div>
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].