0.11.0 • Published 1 year ago

@burger-editor/frozen-patty v0.11.0

Weekly downloads
2
License
MIT
Repository
github
Last release
1 year ago

frozen-patty

npm version Build Status Coverage Status

Pure HTML to JSON converter that not use template engine.

Install

$ npm install -D @burger-editor/frozen-patty

Usage

Extraction

import FrozenPatty from 'frozen-patty';

FrozenPatty('<div data-field="text">value</div>').toJSON(); // => { text: 'value' }
FrozenPatty('<div data-field="field-name">value</div>').toJSON(); // => { 'field-name': 'value' }
FrozenPatty('<a href="http://localhost" data-field="href:href">link</a>').toJSON(); // => { 'href': 'http://localhost' }

FrozenPatty('<div data-bge="text">value</div>', { attr: 'bge' }).toJSON(); // => { text: 'value' }

Data merge

FrozenPatty('<div data-field="text">value</div>').merge({ text: 'merged' }).toHTML(); // => "<div data-field="text">merged</div>";

API

FrozenPatty (html, options)

Extraction data from HTML.

arguments

argstyperequireddescriptions
htmlstringrequiredOriginal HTML
optionsObjectoptional

options†

optionstypedefaultdescriptions
attrstring"field"Data attribute name for specifying the node that FrozenPatty treats as a field

merge (data)

Data merge

argstyperequireddescriptions
dataObjectrequiredNew data

toJSON

Data to plain Object.

toHTML

Render to HTML as string.

0.11.0

1 year ago

0.10.0

3 years ago

0.9.0

6 years ago

0.8.0

7 years ago

0.7.3

7 years ago

0.7.2

8 years ago

0.7.1

8 years ago

0.7.0

8 years ago

0.6.0

8 years ago

0.5.0

8 years ago

0.4.2

8 years ago

0.4.1

8 years ago

0.4.0

8 years ago

0.3.0

8 years ago

0.2.0-beta

8 years ago

0.1.0-beta

8 years ago