an MVC framework for Node
Pull request Compare This branch is 422 commits behind Medium:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin
src
.gitignore
LICENSE
README.md
package.json

README.md

Matador

Sane defaults and a simple structure, scaling as your application grows. Matador is a clean, organized framework for Node.js architected to suit MVC enthusiasts. It gives you a well-defined development environment with flexible routing, easy controller mappings, and basic request filtering. It’s built on open source libraries such as Hogan.js for view rendering, Klass for its inheritance model, Valentine for functional development, and Express to give a bundle of other Node server related helpers.

Installation

Get the CLI

$ npm install matador -g

Create an app

$ matador my-app
$ cd !$ && npm install matador

Start your app

$ cd my-app && node server.js

Dancing with the Bulls

Build on your app

// app/config/routes.js
['get', '/', 'Home', 'hello/:name']

// app/controllers/HomeController.js
hello: function (name) {
  this.response.send('hello' + name)
}

View Rendering

Uses Twitters Hogan.js with layouts, partials, and i18n support.

// app/controllers/HomeController.js
this.response.render('index', {
  title: 'Hello Bull Fighters'
})
<!-- app/views/layout.html -->
<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <title>{{title}}</title>
  </head>
  <body>
    {{{body}}}
  </body>
</html>
<!-- app/views/index.html -->
<h1>{{title}}</h1>

Request Filtering

// app/controllers/ApplicationController.js
module.exports = require('./BaseController').extend(function () {
  this.addBeforeFilter(this.requireAuth)
  this.addExcludeFilter(['welcome'], this.requireAuth)
})
  .methods({
    requireAuth: function (callback) {
      if (this.request.cookies.authed) return callback(null)
      this.response.redirect('/welcome')
    }
  , welcome: function () {
      this.render('welcome')
    }
  })

Authors

Obviously, Dustin Senos & Dustin Diaz

License

Copyright 2012 Obvious Corporation

Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0