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
- Host: GitHub
- URL: https://github.com/marcomilon/micro-form-js
- Owner: marcomilon
- Created: 2021-03-15T01:12:27.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-03-28T21:26:59.000Z (almost 5 years ago)
- Last Synced: 2024-04-15T07:26:50.349Z (almost 2 years ago)
- Language: JavaScript
- Size: 97.7 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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.