Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jesstelford/fe-html-model-decoder

Decode model data as encoded in a page's HTML
https://github.com/jesstelford/fe-html-model-decoder

Last synced: about 1 month ago
JSON representation

Decode model data as encoded in a page's HTML

Awesome Lists containing this project

README

        

# HTML Model Decoder

## Example

```html
{"foo":"bar","zip":[1,2,3]}
```

```javascript
var htmlModeDecoder = require('@domain-group/fe-html-model-decoder');

var decoded = htmlModeDecoder(document.getElementById('model'));

// {foo: 'bar', zip: [1, 2, 3]}
```

## Usage

**`function(DOMNode node)`**

A single function is exported, which expects a DOMNode as its first and only
parameter. This DOMNode should contain some HTML Encoded JSON to be decoded and
returned.

## Credit

Modified from [IdentityServer3](https://github.com/IdentityServer/IdentityServer3/blob/a6e2b6bdfd1516af6cd9fdc9f46a08bb23bb553e/source/Core/Services/DefaultViewService/HttpAssets/app/app.js#L12-L23)