sheet-router
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -49,4 +49,4 @@ const wayfarer = require('wayfarer') | ||
assert.equal(typeof route, 'string', 'route must be a string') | ||
router.apply(null, sliced(arguments)) | ||
return router.apply(null, sliced(arguments)) | ||
} | ||
} |
{ | ||
"name": "sheet-router", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Fast, modular client router", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -87,2 +87,47 @@ # sheet-router [![stability][0]][1] | ||
### virtual-dom example | ||
```js | ||
const render = require('virtual-dom/create-element') | ||
const sheetRouter = require('sheet-router') | ||
const h = require('virtual-dom/h') | ||
const router = sheetRouter(function (route) { | ||
return [ | ||
route('/foo/bar', function (params, h, state) { | ||
h('div', null, 'hello world') | ||
} | ||
] | ||
}) | ||
const node = render(router('/foo', h, { name: 'Jane' })) | ||
document.body.appendChild(node) | ||
``` | ||
```html | ||
<body> | ||
<div>hello world</div> | ||
</body> | ||
``` | ||
### react example | ||
```js | ||
const sheetRouter = require('sheet-router') | ||
const render = require('react-dom') | ||
const react = require('react') | ||
const router = sheetRouter(function (route) { | ||
return [ | ||
route('/foo/bar', function (params, h, state) { | ||
h('div', null, 'hello world') | ||
} | ||
] | ||
}) | ||
render(router('/foo', react.createElement, { name: 'Jane' }), document.body) | ||
``` | ||
```html | ||
<body> | ||
<div>hello world</div> | ||
</body> | ||
``` | ||
## API | ||
@@ -100,2 +145,3 @@ ### router = sheetRouter(dft?, createTree(route)) | ||
- [virtual-dom][13] | ||
- [hyperx][14] | ||
@@ -118,2 +164,3 @@ ## License | ||
[12]: https://github.com/yoshuawuyts/wayfarer | ||
[13]: https://github.com/matt-esch/virtual-dom | ||
[13]: https://github.com/Matt-Esch/virtual-dom | ||
[14]: https://github.com/substack/hyperx |
8180
164