clebert / snugjs-html

Create HTML elements and fragments using JSX.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

@snugjs/html

Create HTML elements and fragments using JSX.

Installation

npm install @snugjs/html

Hello World

import {createElement} from '@snugjs/html';

document.body.appendChild(<h1>Hello, World!</h1>);
document.body.appendChild(createElement('h1', {}, 'Hello, World!'));

<Hello /> Element Factory

import {createElement, createElementFactory} from '@snugjs/html';

const Hello = createElementFactory('h1', (element, childNodes) => {
  element.replaceChildren('Hello, ', ...childNodes, '!');
});

document.body.appendChild(<Hello>World</Hello>);

TypeScript Configuration

{
  "jsx": "react",
  "jsxFactory": "createElement",
  "jsxFragmentFactory": "createFragment"
}

About

Create HTML elements and fragments using JSX.

License:MIT License


Languages

Language:TypeScript 100.0%