dscript
Framework agnostic hyperscript
Should work with any JSX pragma that works out of the box with Babel's JSX implementation or a function that accepts an HTML tag or component, attributes object, and children list.
Install
npm install --save dscript
Note: Webpack users will need to setup a json-loader as dscript relies on html-tags, which uses a JSON file
General Usage
const div li ul = const handleClick =
Usage with React
It is recommended to use dscript-react to remove dscript boilerplate.
Take the following:
<ul> propsitems </ul>
or:
and instead write:
const li ul =
Usage with Deku
It is recommended to use dscript-deku to remove dscript boilerplate.
Take the following:
<ul> propsitems
or:
and instead write:
const li ul =
Usage with Custom Components
Custom components example is shown using React, but works with any framework that works with dscript's basic functionality.
const creator = const div li ul = creatorconst customComponentCreator = const handleClick =
API
dscript(createElement)
Returns an object with properties consisting of HTML tags with values being creator functions.
createElement
type: function
A function to use to create the Virtual DOM. For example, React's createElement
or Deku's element
.
dscript(createElement)(customComponent)
Returns a creator function to be used in dscript.
For example:
const creator = const div = creatorconst custom =
createElement
Same as above
customComponent
type: any
Should be a valid component for the createElement
function.
Creator Functions
creatorFunction([cssClassesAndOrIdSelector,] [attributes,] [children])
A function that returns a virtual DOM node created with createElement
.
cssClassesAndOrIdSelector
type: string
default: null
A convenience to add class names and an id to a virtual DOM node. Note: The provided selector will override attribute
's class and id.
attributes
type: object
default: {}
An object that will be passed as the attributes to the virutal DOM node.
children
type: ...Elements
default: []
The list of children passed to the created virtual DOM node.
LICENSE
MIT © Dustin Specker