git ssb

1+

Matt McKegg / pull-hyperscript



Branch:
mix irving committed 0.2.2Latest: 3c3217e on 11/10/2016, 8:33:45 AM
📄.gitignore
📄README.md
📄index.js
📁lib
📄package.json
📄test.js
README.md

pull-hyperscript

Create HyperText a la hyperscript, but return the html as a pull-stream.

This allows streaming the view to the browser as it continues to render.

const h = require('pull-hyperscript')
const pull = require('pull-stream')

pull(
  h('div', {class: 'i'}, [
    h('div', {}, [
      h('p', {}, 'yes!')
    ])
  ]),
  pull.concat((err, html) => {
    if (err) throw err
    t.equal(html, '<div class="i"><div><p>yes!</p></div></div>', 'renders html')
    t.end()
  })
)

pull(
  h('div', {class: 'i'}, pull(
    pull.values(['yes', null, 'non']),
    pull.filter(Boolean),
    map(val => h('p', val)),
    flatten()                        // NB: flatten turns a stream of streams into a single stream
  )),
  pull.concat((err, html) => {
    if (err) throw err
    var expected = '<div class="i"><p>yes</p><p>non</p></div>'
    t.equal(html, expected, 'renders html')
    t.end()
  })
)

TODO

Built with git-ssb-web