Skip to content
/ h2array Public

Create compact array trees resembling h() calls

Notifications You must be signed in to change notification settings

jamen/h2array

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

h2array

['header', [
  ['h1', 'hello world'],
  ['nav', [
    ['a', { href: '/foo' }, 'foo'],
    ['a', { href: '/bar' }, 'bar'],
    ['a', { href: '/baz' }, 'baz']
  ]]
]]

This module provides a variant of h() for storing calls as arrays, allowing you to serialize them as JSON for later use.

usage

NPM

h(tag, attributes?, children?)

Stores tag, attributes, and children in an array. Handles any missing arguments according to hyper2/h2spec.

> const h = require('h2array')
> h('h1', 'hello world')
['h1', null, 'hello world']

convert(h, node)

Applies h to node and all its children.

> const convert = require('h2array/convert')
> const h2ml = require('h2ml')
> const tree = ['h1', { style: 'color: red' }, 'hello world']
> convert(h2ml, tree)
"<h1 style='color: red'>hello world</h1>"

About

Create compact array trees resembling h() calls

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published