发布于 2014-08-25 23:52:24 | 164 次阅读 | 评论: 0 | 来源: 网友投递
Derby.js javascrript MVC 框架
Derby 是一个 javascrript 的MVC 框架,帮助编写实时,交互的应用。可以运行在 Node.js 或者浏览器环境中。
Derby.js 0.6.0-alpha24 发布,现已提供下载,更多内容请看这里。
Derby 是一个 MVC 框架,帮助编写实时,交互的应用。可以运行在 Node.js 或者浏览器环境中。
示例代码:
var hello = require('derby').createApp(module) , view = hello.view , get = hello.get;// Templates define both HTML and model <- -> view bindingsview.make('Body', 'Holler: <input value="{message}"><h1>{message}</h1>');// Routes render on client as well as serverget('/', function (page, model) { // Subscribe specifies the data to sync model.subscribe('message', function () { page.render(); });});
var express = require('express') , expressApp = express() , server = require('http').createServer(expressApp);// The server-side store syncs data over Socket.IOvar 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);