![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
hyperx
Advanced tools
Readme
tagged template string virtual dom builder
This module is similar to JSX, but provided as a standards-compliant ES6 tagged template string function.
hyperx works with virtual-dom,
react,
hyperscript, or any DOM builder with a
hyperscript-style API: h(tagName, attrs, children)
.
You might also want to check out the hyperxify browserify transform to statically compile hyperx into javascript expressions to save sending the hyperx parser down the wire.
Template strings are available in: node 4+, chrome 41, firefox 34, edge, opera 28, safari 9
If you're targeting these platforms, there's no need to use a transpiler!
var vdom = require('virtual-dom')
var hyperx = require('hyperx')
var hx = hyperx(vdom.h)
var title = 'world'
var wow = [1,2,3]
var tree = hx`<div>
<h1 y="ab${1+2}cd">hello ${title}!</h1>
${hx`<i>cool</i>`}
wow
${wow.map(function (w, i) {
return hx`<b>${w}</b>\n`
})}
</div>`
console.log(vdom.create(tree).toString())
output:
$ node vdom.js
<div>
<h1 y="ab3cd">hello world!</h1>
<i>cool</i>
wow
<b>1</b><b>2</b><b>3</b>
</div>
var React = require('react')
var toString = require('react-dom/server').renderToString
var hyperx = require('hyperx')
var hx = hyperx(React.createElement)
var title = 'world'
var wow = [1,2,3]
var tree = hx`<div>
<h1 y="ab${1+2}cd">hello ${title}!</h1>
${hx`<i>cool</i>`}
wow
${wow.map(function (w, i) {
return hx`<b>${w}</b>\n`
})}
</div>`
console.log(toString(tree))
var h = require('hyperscript')
var hyperx = require('hyperx')
var hx = hyperx(h)
var title = 'world'
var wow = [1,2,3]
var tree = hx`<div>
<h1 y="ab${1+2}cd">hello ${title}!</h1>
${hx`<i>cool</i>`}
wow
${wow.map(function (w) {
return hx`<b>${w}</b>\n`
})}
</div>`
console.log(tree.outerHTML)
var vdom = require('virtual-dom')
var hyperx = require('hyperx')
var hx = hyperx(vdom.h)
var main = require('main-loop')
var loop = main({ times: 0 }, render, vdom)
document.querySelector('#content').appendChild(loop.target)
function render (state) {
return hx`<div>
<h1>clicked ${state.times} times</h1>
<button onclick=${onclick}>click me!</button>
</div>`
function onclick () {
loop.update({ times: state.times + 1 })
}
}
var React = require('react')
var render = require('react-dom').render
var hyperx = require('hyperx')
var hx = hyperx(React.createElement)
var App = React.createClass({
getInitialState: function () { return { n: 0 } },
render: function () {
return hx`<div>
<h1>clicked ${this.state.n} times</h1>
<button onClick=${this.handleClick}>click me!</button>
</div>`
},
handleClick: function () {
this.setState({ n: this.state.n + 1 })
}
})
render(React.createElement(App), document.querySelector('#content'))
var hyperx = require('hyperx')
var convertTaggedTemplateOutputToDomBuilder = hyperx(function (tagName, attrs, children) {
console.log(tagName, attrs, children)
})
convertTaggedTemplateOutputToDomBuilder`<h1>hello world</h1>`
// Running this produces: h1 {} [ 'hello world' ]
var hyperx = require('hyperx')
Return a tagged template function hx
from a hyperscript-style factory function
h
.
Values to use for h
:
vdom.h
React.createElement
Optionally provide:
opts.concat(a, b)
- custom concatenation function to combine quasiliteral
strings with expressions. The h
factory function will receive the objects
returned by the concatenation function and can make specific use of them. This
is useful if you want to implement a pre-processor to generate javascript from
hyperx syntax.opts.attrToProp
- turn off attribute to property conversions when false
BSD
npm install hyperx
FAQs
tagged template string virtual dom builder
The npm package hyperx receives a total of 43,804 weekly downloads. As such, hyperx popularity was classified as popular.
We found that hyperx demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 27 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.