Hyper Text JSON
Install
npm i htjson
Usage
const htjson = let json = ...let html = htjson
Format Example
Simple tag
title content
equals
moduleexports = div: h1: 'title' span: 'content'
Tag with attribute
foo
from
moduleexports = span: _class: 'foo' $text: 'foo'
Multiple children without attributes
london London is the capital city of England. It is the most populous city in the United Kingdom, with a metropolitan area of over 13 million inhabitants. Standing on the River Thames, London has been a major settlement for two millennia, its history going back to its founding by the Romans, who named it Londinium.
from
moduleexports = article: h1: 'london' p: 'London is the capital city of England. It is the most populous city in the United Kingdom, with a metropolitan area of over 13 million inhabitants.' p: 'Standing on the River Thames, London has been a major settlement for two millennia, its history going back to its founding by the Romans, who named it Londinium.'
Multiple children with attribute
divs first london Paris Tokyo
from
moduleexports = div: _class: 'abc' $: 'divs' span: 'first' div: a: _href: '#' $text: 'london' div: a: _href: '#' $text: 'Paris' div: a: _href: '#' $text: 'Tokyo'
Options
Indent
const htjson = htjsonindent = '\t' // default 2 spaces