0.2.2 • Published 10 years ago

pull-hyperscript v0.2.2

Weekly downloads
5
License
MIT
Repository
-
Last release
10 years ago

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

  • Should support some kind of automatic text escaping.
  • props should generate the the same html as hyperscript. Should probably rip some code out of html-element.
  • ES5 compat? Discuss if this module should work in older (non-serverside) JS runtimes. How should we go about supporting this?
0.2.2

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.0

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago