0.1.5 • Published 3 years ago

domguy v0.1.5

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
3 years ago

domguy

generate dom trees from js

Install

npm install domguy

Usage

import { chainable, elements } from 'domguy'
import { writeFileSync } from 'fs'

const root = chainable({ prettify: true })
const { head, meta, title, body, div, h1 } = elements

const page = root
  .html(
    [
      head([
        meta({
          std: [['charset', 'UTF-8']],
        }),
        meta({
          std: [
            ['http-equiv', 'X-UA-Compatible'],
            ['content', 'IE=edge'],
          ],
        }),
        meta({
          std: [
            ['name', 'viewport'],
            ['content', 'width=device-width, initial-scale=1.0'],
          ],
        }),
        title('Document'),
      ]),
      body(
        [
          div(h1('Hello World!'), {
            std: [
              ['style', ['display:flex;', 'justify-content:space-between;']],
            ],
          }),
        ],
        {
          std: [['style', 'margin:128px;']],
        }
      ),
    ],
    {
      std: [['lang', 'en']],
      nstd: [['non-standard-attribute', 'value']],
    }
  )
  .toString()

writeFileSync('page.html', page, 'utf8')
0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago