SuitUp.js is an Open Source Javascript OOP-MVC framework that allows you to create sweet apps with less code. SuitUp.js comes with jquery included, so you are free to use your jquery plugins without inconvenients or hacks. Also, any change in your model instances will result in DOM updates.
SuitUp.js uses Handlebars as template language and a virtual copy of your DOM. When your data changes, SuitUp.js re-render the template and updates the virtual tree.
SuitUp.js is in early development.
Components
Create components by extending from SuitUp.Component Class. Instances of the component are created from any template you want.
var { SuitUpComponent;};HeaderComponentprototype = Object;HeaderComponentprototypeconstructor = HeaderComponent;
Routing
Creating routes is easy and clean in suitup. Just specify the route, component name and a callback function.
app.js
var router = SuitUpRouter; var index = router; var friends = router; var friend = router;
Templates
SuitUp uses handlebars. It's fast and easy. Call a template with the partial helper. Create a component instance with the component helper. Load templates based on url with the context helper. Load static templates with partial helper.
application.handlebars
{{{component "HeaderComponent" model "header"}}} {{{context}}} {{{partial "footer"}}}
Update your model when inputs change.
component.handlebars
{{{model.text}}}
Components inside other components
In SuitUp, components are encapsulated reducing coupling. You can define a component inside another component in your template and access to the component instance. For example, if you have 2 components, IndexComponent and HeaderComponent, you can define the IndexComponent template, index.handlebars like this:
- first argument: The Component Class.
- second argument: The Model to use.
- third argument: A property name to access the child Component from parent component.
index.handlebars
{{{component "HeaderComponent" model "headerComponent"}}} this is index
Then, if you have an instance of your IndexComponent called index, you can access to your header data like this:
//firstvar headerModel = indexheaderComponent;//then you can update your model and your Html will be updated.var headerTitle = headerModel;//you can do this toovar link = headerModel;
Running example
If not enough documentation here, check the example included. Just execute the server file included in the example folder. Then open it in your browser http://localhost:4200/
$ cd example$ node server.js
Including it in your html
Just include suitup.min.js from dist folder and your compiled handlebars templates.
TODO
- Model Class
- More helpers
Contributing
You are free to hack, modify or improve this code.
Thanks
- virtual-dom - A Virtual DOM and diffing algorithm
- handlebars - Logicless templating language