basicjsx
v1.2.1
Published
<a href="https://www.npmjs.com/package/basicjsx"><img src="https://img.shields.io/npm/v/basicjsx"></img></a> <a href="https://www.npmjs.com/package/basicjsx"><img src="https://img.shields.io/npm/dw/basicjsx"></img></a> <a href="https://github.com/tnichols
Downloads
9
Readme
basicJSX
A simple implementation of JSX without React for basic server side rendering applications.
Usage
Import package as React
import React from "basicjsx"
Now any JSX will be converted into HTMLElement
s (using linkedom).
Custom Elements
Custom elements can be written as a function of the type
(props: Object, children: HTMLElement[]) => HTMLElement
Where props
are key-value pairs of the html properties of the element (ie. the style tag on an element), and children
is a list of all contained elements
Default Custom Elements
Some default custom elements are provided as CustomElements
in the package and can be imported with
import {CustomElements} from "basicjsx"
CustomElements.Insert
inserts an HTMLElement from theobj
property
(ie.<CustomElements.Insert obj={<p></p>}></CustomElements.Insert>
becomes<p></p>
)CustomElements.Render
renders HTML in thehtml
property into HTMLElements.
THIS IS AN UNSAFE METHOD, NO INPUT VALIDATION IS BEING DONE, SANITIZE INPUT BEFORE USING.
(ie.<CustomElements.Render html="<p>1</p>"></CustomElements.Render>
renders to<p>1</p>
as an HTMLElement