https://github.com/mlms13/integrant
Generate forms automatically given a structured JSON schema
https://github.com/mlms13/integrant
Last synced: 9 months ago
JSON representation
Generate forms automatically given a structured JSON schema
- Host: GitHub
- URL: https://github.com/mlms13/integrant
- Owner: mlms13
- Created: 2014-06-27T05:22:57.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-07-12T22:58:36.000Z (over 11 years ago)
- Last Synced: 2025-02-13T05:18:29.845Z (11 months ago)
- Language: JavaScript
- Homepage:
- Size: 180 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Integrant
Integrant is a form generator for Node.js and the browser. Inspired by [Mongoose Schema Types](http://mongoosejs.com/docs/schematypes.html), you can define your data structure with JSON, and Integrant will generate forms to populate the data.
## Getting Started
Integrant is built around CommonJS modules. To use Integrant in the browser, include the entire `src` folder from this repository in your project. Using [Browserify](http://browserify.org/), require `src/integrant.js`.
```javascript
var Integrant = require('./src/integrant.js');
```
To create HTML from a JSON schema, run Integrant's `generate` function, passing in your schema as the only parameter.
```javascript
var html = Integrant.generate({
"title": "string",
"pubDate": "date"
// ...
});
```
See the `demo` folder for a more complete example.
## Creating Custom Types
Currently, Integrant only supports `"string"`, `"number"`, and `"date"` out of the box. You can add your own custom types by passing a type name and a definition object to Integrant's `registerType` method.
```javascript
Integrant.registerType("primayColor", {
template: require('color.hbs')
});
```
You aren't required to use handlebars for you templates. Any templating language that compiles to produce a string of HTML will work. See `src/types` for examples of templates.
## Changelog
### 0.1
- Proof of conecpt with three basic types (string, number, date)
- Ability to register new types