New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

callbag-html

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

callbag-html

An html markup library for callbag

latest
Source
npmnpm
Version
0.2.0
Version published
Maintainers
1
Created
Source

callbag-html

An html markup library for callbag

Example

const { div, span, br } = require('callbag-html')
const { pipe, map, interval } = require('callbag-basics')

// A callbag stream of an HTMLElement
const clock =
  pipe(
    interval(1000),
    map(() => span(`The time is ${new Date().toString()}`))
  )

document.body.appendChild(
  div([
    span('The time is:'), // Can accept ordinary markup
    br(), // Variadic functions for clean looking markup
    clock // Accepts callbag streams of elements!!
  ])
)

API

The API is very similar to r-dom's, except that it can accept callbag streams for seamless interop and it returns real HTMLElements

This doc assumes the library was imported as const h = require('callbag-html'). The function is variadic:

h[tagName]([innerText])

Returns an HTMLElement

  • tagName String - An HTMLElement tag name
  • innerText String - The innerText of the element

h[tagName]([children])

Returns an HTMLElement

  • tagName String - An HTMLElement tag name
  • children Array[HTMLElement|Stream[HTMLElement]] - An array where each element can be an HTMLElement or a callbag stream of an HTMLElement

h[tagName]([children$])

Returns an HTMLElement

  • tagName String - An HTMLElement tag name
  • children$ Stream[Array[HTMLElement|Stream[HTMLElement]]] - A callbag stream of an array where each element can be an HTMLElement or a callbag stream of an HTMLElement

h[tagName]([properties], [innerText])

Returns an HTMLElement

  • tagName String - An HTMLElement tag name
  • properties Object - An object with property/value pairs
  • innerText String - The innerText of the element

h[tagName]([properties], [children])

Returns an HTMLElement

  • tagName String - An HTMLElement tag name
  • properties Object - An object with property/value pairs
  • children Array[HTMLElement|Stream[HTMLElement]] - An array where each element can be an HTMLElement or a callbag stream of an HTMLElement

h[tagName]([properties], [children$])

Returns an HTMLElement

  • tagName String - An HTMLElement tag name
  • properties Object - An object with property/value pairs
  • children$ Stream[Array[HTMLElement|Stream[HTMLElement]]] - A callbag stream of an array where each element can be an HTMLElement or a callbag stream of an HTMLElement

Argument Examples

  • properties

    • { id: 'foo', style: { fontSize: '12px' }, className: 'bar', classSet: { toggled: true } }
  • children

    • [span('foo'), span('bar'), span('baz')]
    • [pipe(interval(1000), map(n => span(n))), span('!')]
    • pipe(interval(500), map(n => [span('N = '), strong(n)]))

Tests

Run npm run watch to generate the test bundle, served by default on localhost:1234

License

See LICENSE

Keywords

html

FAQs

Package last updated on 09 Nov 2018

Did you know?

Socket

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.

Install

Related posts