Derby.js javascrript MVC 框架

Derby 是一个 Javascrript 的MVC 框架,帮助编写实时,交互的应用。可以运行在 Node.js 或者浏览器环境中。

示例代码:
Hello.js

var hello = require('derby').createApp(module)
  , vIEw = hello.view
  , get = hello.get;

// Templates define both HTML and model <- -> view BINDings
view.Make('Body'
, 'Holler: <input value="{message}"><h1>{message}</h1>'
);

// Routes render on client as well as server
get('/', Function (page, model) {
  // Subscribe SPEcifies the Data to sync
  model.subscribe('message', function () {
    page.render();
  });
});

server.js

var Express = require('express')
  , expressApp = express()
  , server = require('HTTP').createServer(expressApp);

// The server-side sTore syncs data over Socket.IO
var store = require('derby').createStore({listen: server});

expressApp
  .use(express.static(__dirname + '/public'))
  // The store creates models for incoming Requests
  .use(store.modElmiddleware())
  // App routes create an Express middleware
  .use(require('./hello').router());

server.listen(3000);

 

Derby.js 0.6.0-alpha24 发布,JS 的 MVC 框架
Derby.js 0.6.0-alpha24 发布,现已提供下载,更多内容请看这里。Derby 是一个 MVC 框架,帮助编写实时,交互的应用。可以运行在 Node.js 或者浏览器环境中。示例代码:hello.jsvar hello = require('derby').createApp(module)  &n

发布于 2014-08-25 23:52:24 | 164 次阅读


Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务