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

https://github.com/marcomilon/micro-form-js

A port of micro-form to JavaScript
https://github.com/marcomilon/micro-form-js

Last synced: 12 months ago
JSON representation

A port of micro-form to JavaScript

Awesome Lists containing this project

README

          

# micro-form-js

A port of micro-form to JavaScript. The goal of this library is to be able to generate an Html Form from JSON.

## Example

**Examples**

**Input**

```javascript

json = [
{
"tag": "input",
"type": "text",
"name": "username",
"class": "form-control"
}
]

console.log(renderForm(input))
```

*output*

```html

```

**Textarea**

```javascript

json = [
{
"tag": "textarea",
"id": "story",
"name": "story",
"rows": "5",
"cols": "33",
"value": "It was a dark and stormy night..."
}
]

console.log(renderForm(input))
```

*output*

```html

It was a dark and stormy night...

```

**Select**

```javascript

json = [
{
"tag": "select",
"name": "pets",
"id": "pet-select",
"value": [
{
"tag": "option",
"label": "--Please choose an option--",
"value": ""
},
{
"tag": "option",
"label": "Dog",
"value": "dog"
},
{
"tag": "option",
"label": "Cat",
"value": "cat"
}
]
}
];

console.log(renderForm(input))
```

*output*

```html

--Please choose an option--
Dog
Cat

```

### Contribution

Feel free to contribute! Just create a new issue or a new pull request.

### License

This library is released under the MIT License.