Lua 語言的 MVC 編程框架,Sailor 0.4 發布
Sailor 是一個 Lua 語言的 MVC 編程框架。支持跨平臺,兼容 mod_lua 或者 mod_pLua, Nginx 的 ngx_lua, 或者任何支持 CGI 的 Web 服務器,如 Civetweb 或者 Mongoose, 前提是必須有 CGILua
使用 Sailor 開發應用的目錄結構如下:
-
/conf - 存放配置文件
</li> -
/controllers - 控制器
</li> -
/layouts - 布局文件
</li> -
/models - 模型
</li> -
/pub - 靜態文件
</li> -
/runtime - 運行時生成的臨時文件
</li> -
/views - .lp 視圖文件
</li> </ul>示例代碼:
local site = {} function site.index(page) local foo = 'Hello world' local User = sailor.model("user") local u = User:new() u.username = "etiene" u.password = "a_password" local valid, err = u:validate() -- validate() will check if your attributes follow the rules! if not valid then foo = "Boohoo :(" end
-- Warning: this is a tech preview and some methods of model class do not avoid SQL injections yet. page:render('index',{foo=foo,name=u.username}) -- This will render /views/site/index.lp and pass the variables 'foo' and 'name' end function site.notindex(page) page:write('Hey you!') end return site</pre>
Sailor 0.4 發布了,該版本集成了 Busted 和一個測試模塊,提供單元和功能測試;同時修復了一些 bug 。接下來的主要工作是:
-
提升客戶端的 Lua 編碼
</li> -
集成 mod_lua 的 DB API 和 DB 模塊
</li> -
ORM 的提升
</li> </ul> https://github.com/Etiene/sailor本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!
-