Socket
Socket
Sign inDemoInstall

jonx

Package Overview
Dependencies
1
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    jonx

Convert between JSON and HTML


Version published
Weekly downloads
1
Maintainers
1
Install size
23.1 kB
Created
Weekly downloads
 

Readme

Source

jonx

Javascript natively works well with JSON, so the idea behind this module is to do UI with JSON as much as possible and finally convert to HTML as the last step.

This would allow building templates that are based purely on JSON and transforming JSON.

NPM info

Travis build status

TODO

This is a work in progress, and some critical functionality is in the works still:

  • There is no browser build though there are no dependencies which would break this for the browser.
  • There is no ability to convert from HTML to json yet
  • There is no ability to transform JSON dynamically (templates).

Install

npm install jonx

API

It is best to read the unit tests under test directory to understand how to use this. The API is still under flux.

Here is a complicated example which cover bulk of the interesting cases.

jonx.json2html({
      body: {
        'div.header': 'First Div',
        'section#main': [
          {div: {
            css: {background: 'black'}, $: [
            {span: 'First Span'},
            {span: 'Second Span'}
            ]}}
        ]
      }
})

Output HTML:

<body>
  <div class="header">First Div</div>
  <section id="main">
    <div style="background:black;">
      <span>First Span</span>
      <span>Second Span</span>
    </div>
  </section>
</body>

Keywords

FAQs

Last updated on 13 Sep 2014

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc