README
Vanilla-JSX-Node
Vanilla-JSX-Node is the node version of the Vanilla-JSX library. This library allows you to render your views written for the browser to string, server side.
Features
- Works without any DOM in env
- Renders JSX to string
- Translates className attribute into class
API
// Responsible for creating HTML Elements from JSX
export function jsx(name, attributes, ...children): Object {}
// To be executed on result from JSX method
export function process(element): string {}
Example
'use babel'
import vanilla from 'vanilla-jsx-node'
/** @jsx vanilla.jsx */
export class Message {
constructor(message) {
this.element = Message.getElement()
console.log(typeof this.element === 'string')
// ^ true!
}
static getElement(message) {
return vanilla.process(<div>
<span>{message.name}</span>
<span>{message.text}</span>
<span>{message.filePath}</span>
{message.trace.map(Message.getElement)}
</div>)
}
}
LICENSE
This project is licensed under the terms of MIT License, See the LICENSE file for more info