npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

jui-builder

v1.1.7

Published

The JUIBuilder is a JavaScript framework that provides a simple and customizable way to generate dynamic HTML content based on structured JSON data.

Downloads

26

Readme

JUIBuilder

The JUIBuilder provides a simple and customizable way to generate dynamic HTML content based on structured JSON data.

Features

  • Convert JSON data to HTML markup
  • Define custom mapping between JSON keys and HTML elements
  • Support for nested JSON objects and arrays
  • Customizable class names and attributes for HTML elements
  • Basic validation of JSON data against a JSON schema

Limitations

  • Referenced data is not processed: If the JSON data contains references to other objects, the JUIBuilder will display placeholder values for these objects, which need further processing to show actual data.

Installation

In your terminal run npm i jui-builder

Usage

Here is an example on how to use this framework:

// (Optional) Define the element configuration map by matching the JSON properties of your data to HTML element references.
// The name of the element needs to match the name of the JSON-property. Per element you can define tag (HTML reference), style (CSS styling), class (HTML class) and sublevel.
// Use sublevel if the JSON property has nested objects, which you want to style specifically. In the sublevel you can define tag and style.
const elementConfigMap = {
    age: {
        tag: 'h3',
        subLevel: {
            name: {
                tag: 'p'
            }
        }
    },
    lastName: {
        tag: 'p',
        style: 'padding: 10px;'
    },
};

// Create an instance of the JUIBuilder class (optionally with own elementConfigMap else leave parameters empty)
const converter = new JUIBuilder(elementConfigMap);

/* (Optional) Define your JSON schema
*/ Define your own JSON schema for the JSON data you want to convert to HTML. The JSON schema needs to follow the 2020-12 schema standard. 
const jsonSchemaOne = {
    "$id": "https://example.com/person.schema.json",
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "title": "Person",
    "type": "object",
    "properties": {
        "firstName": {
            "type": "string",
            "description": "The person's first name."
        },
        "lastName": {
            "type": "string",
            "description": "The person's last name."
        },
        "age": {
            "description": "Age in years which must be equal to or greater than zero.",
            "type": "integer",
            "minimum": 0
        }
    }
};

// Define your JSON data which you want to convert to HTML
const example = {
    "firstName": "John",
    "lastName": "Doe",
    "age": 21
};

// Convert the JSON data to HTML (optional with own jsonSchema else leave parameters empty)
const html = converter.processEventData(jsonData, jsonSchema);