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

json2htmlform

v0.6.3

Published

Converts json documents to html5 forms

Downloads

2

Readme

##Summary

json2htmlform is a simple program to take a well formed JSON document and convert it into an HTML5 form

The following form tags are currently supported;

Every form must have the following mandatory tags;

##Tag definitions

Only supported attributes can be used. For all tags, you must define a tag attribute. All other attributes are optional. Using attributes not defined here will cause the conversion to fail.

INPUT

If a label attribute is defined, a label tag will be prepended to the html above the tag.

Supported attributes;

Examples;

{
		"type": "text",
		"name": "wibble",
		"id": "wibble",
		"tag": "input",
		"placeholder": "wibble",
		 "label":"text box"
}, {
		"type": "checkbox",
		"name": "bike",
		"id": "bikecb",
		"tag": "input",
		"value": "bike",
		"label": "Bike"
	}, {
		"type": "checkbox",
		"name": "car",
		"id": "carcb",
		"tag": "input",
		"value": "car",
		"label": "Car"
}

SELECT

optgroups and options attributes can not be combined in a single select.

If a label attribute is defined, a label tag will be prepended to the html above the tag.

Supported attributes;

Examples;

{
		"tag": "select",
		"optgroups": [
			{
				"label": "Swedish Cars",
				"options": ["volvo", "saab"]
			}, {
				"label": "German Cars",
				"options": ["mercedes", "bmw", "audi"]
			}
		],
		"label": "select a car by country",
		"id": "selectcarbycountry"
	}, {
		"tag": "select",
		"options": ["mercedes", "bmw", "audi", "volvo", "saab"],
		"label": "select a car",
		"id": "selectcar"
	}

BUTTON

Supported attributes;

Examples;

{
		"type": "button",
		"name": "button",
		"id": "buttonbutton",
		"tag": "button",
		"text": "button"
	} , {
		"type": "reset",
		"name": "reset",
		"id": "resetbutton",
		"tag": "button",
		"text": "reset"
	}, {
		"type": "submit",
		"name": "submit",
		"id": "submitbutton",
		"tag": "button",
		"text": "submit"
	}
	

TEXTAREA

Supported attributes;

Example;

{
		"name": "txtarea",
		"id": "mytextarea",
		"tag": "textarea",
		"placeholder": "wibble",
		"label": "this is a text area"
	}
	

##Usage

from the command prompt / terminal type

node main.js --source file --target file

or type

node main.js --help

to display usage instructions

##Full Example

run

node main.js --source testdata/example.json --target example.html

to see a worked example. The JSON used is reproduced below

{
"name": "Example Form",
"action": "example.html",
"method": "post",
"html": [
	{
		"type": "text",
		"name": "wibble",
		"id": "wibble",
		"tag": "input",
		"placeholder": "wibble",
		 "label":"text box"
	} , {
		"type": "text",
		"name": "wobble",
		"id": "wobble",
		"tag": "input",
		"placeholder": "wobble"
	}, {
		"type": "checkbox",
		"name": "bike",
		"id": "bikecb",
		"tag": "input",
		"value": "bike",
		"label": "Bike"
	}, {
		"type": "checkbox",
		"name": "car",
		"id": "carcb",
		"tag": "input",
		"value": "car",
		"label": "Car"
	}, {
		"type": "radio",
		"name": "sex",
		"id": "secm",
		"tag": "input",
		"value": "male",
		"label": "Male"
	}, {
		"type": "radio",
		"name": "sex",
		"id": "secf",
		"tag": "input",
		"value": "female",
		"label": "Female"
	}, {
		"type": "password",
		"name": "mypassword",
		"id": "password",
		"tag": "input",
		"placeholder": "password"
	}, {
		"tag": "select",
		"optgroups": [
			{
				"label": "Swedish Cars",
				"options": ["volvo", "saab"]
			}, {
				"label": "German Cars",
				"options": ["mercedes", "bmw", "audi"]
			}
		],
		"label": "select a car by country",
		"id": "selectcarbycountry"
	}, {
		"tag": "select",
		"options": ["mercedes", "bmw", "audi", "volvo", "saab"],
		"label": "select a car",
		"id": "selectcar"
	}, {
		"name": "txtarea",
		"id": "mytextarea",
		"tag": "textarea",
		"placeholder": "wibble",
		"label": "this is a text area"
	}, {
		"type": "button",
		"name": "button",
		"id": "buttonbutton",
		"tag": "button",
		"text": "button"
	} , {
		"type": "reset",
		"name": "reset",
		"id": "resetbutton",
		"tag": "button",
		"text": "reset"
	}
],
"enctype": "multipart/form-data"
}