string-dom
Create HTML strings using JSX (or functions).
Install
$ npm i string-dom --save
About
string-dom
is a function that creates an HTML string. It is meant to work with JSX, but does not create DOM (regular or virtual). It effectively turns JSX into an HTML templating language that can be used separately of React.
Usage
import sd from 'string-dom' /** @jsx sd */ // with JSX// note the comment above, and see the link below// https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-react-jsx#customdocumentbodyinnerHTML += <div ="wrapper"> <h1 ="heading" ="data-heading">Heading Text</h1> <p ="heading-sub" ="data-subheading">Subheading Text</p> <p>An element without attributes</p> </div> // without JSXdocumentbodyinnerHTML +=
Both the above generate the following HTML (as a string), then add it to the body
:
Heading Text Subheading Text An element without attributes.
Prior Art
Linting
License
MIT. © 2017 Michael Cavalea