Lettuce是一个小的(~6kb)、强大的移动开发框架 for Romantic.
在线演示 http://phodal.github.io/lettuce.
Usage(用法)
Class(类)
javascript
var L = new lettuce(); var zero = function(){ }; var sub = new L.Class(zero);
Template(模板)
javascript
var L = new lettuce(); var data = { "title": "JavaScript Templates" }; var result = L.Template.tmpl(" <h3>{%=o.title%}</h3> \n!@#$%^&*()-=", data);
Router(路由)
javascript
var L = new lettuce(); var check = L.Router .add(/#about/,log) .add(/#what/, log) .add(/#why/, log) .load();;
Promise
javascript
function late(n) { var L = new lettuce(); var p = new L.Promise(); return p; } late(100).then( ).then( ).done();
Ajax
javascript
lettuce.get('/bower.json', function(result){ equal(result["name"], "lettuce"); done(); })
javascript
lettuce.post("http://127.0.0.1:5000/some", "something", function(data){ console.log(data) })
Single Page Application Example(单页面应用)
1.创建实例
javascript
var L = new lettuce();
2.定义数据
javascript
var data = { about: "Template", what: "This about A Mobile Framework For Romantic", why: "Why is a new Framework" };
3.创建路由函数
javascript
var aboutPage = function(){ var aboutPage = new L.SimpleView(); var templates = L.Template.tmpl(" <h3>{%=o.about%}</h3> ", data); return aboutPage.render(templates, "results"); }; var whyPage = function(){ var whyPage = new L.SimpleView(); var templates = L.Template.tmpl(" <h3>{%=o.why%}</h3> ", data); return whyPage.render(templates, "results"); }; var whatPage = function(){ var whatPage = new L.SimpleView(); var templates = L.Template.tmpl(" <h3>{%=o.what%}</h3> ", data); return whatPage.render(templates, "results"); };
4.添加路由
javascript
L.Router .add(/#about/, about) .add(/#what/, what) .add(/#why/, why) .load();
示例
http://valentine.phodal.com/
http://lettuce.phodal.com/
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。