New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

json-template-builder

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-template-builder

Easy way to create template (e.g. Vue Template) from JSON.

latest
npmnpm
Version
1.1.3
Version published
Maintainers
1
Created
Source

JSON Template Builder

The easiest way to create template (for example Vue template) from JSON object.
Also you can build DOM tree with it.

Installation

npm install json-template-builder

Help

createTree() - function.
1 argument - JSON object
returns DOM tree

treeToStringTemplate() - function.
2 arguments: DOM tree & parent tag
returns string representation of a given DOM tree wrapped in parent tag (default <template>)

json object example:

let model = {
    el: {
        tag: 'div',
        attrs: {'class': 'body-1', 'style': 'color: red;'},
        children: [
            {
                {
                    tag: 'span',
                    children: 'example text'
                }
            }
        ]
    }
};

minimal model:

let model = {
  el: {}
}

It`s equal to <div></div>.

tag - any js string which supported by HTML as tag-name; if empty then <div>.
attrs - object with pairs key-value, key is attribute name, value is attribute value; can be empty.
children - string or Array. if string use it as innerHTML of node. If Array - creates children nodes. Can be empty.
Root node in model should only be one and called as el.

Usage

import {createTree, treeToStringTemplate} from 'json-template-builder';

Contact

vladivanov.dev@gmail.com

Keywords

json

FAQs

Package last updated on 31 Mar 2019

Did you know?

Socket

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