Lettuce 移动框架 for Romantic

Lettuce

Lettuce是一个小的(~6kb)、强大的移动开发框架 for Romantic.

在线演示 http://phodal.github.io/lettuce.

Usage(用法)

Class(类)

javascriptvar L = new lettuce();
var zero = function(){

};
var sub = new L.Class(zero);

Template(模板)

javascriptvar L = new lettuce();
var data = {
    "title": "JavaScript Templates"
};

var result = L.Template.tmpl("

<h3>{%=o.title%}</h3>

\n!@#$%^&*()-=", data);

Router(路由)

javascriptvar L = new lettuce();

var check = L.Router
            .add(/#about/,log)
            .add(/#what/, log)
            .add(/#why/, log)
            .load();;

Promise

javascriptfunction late(n) {
    var L = new lettuce();
    var p = new L.Promise();
    return p;
}

late(100).then(
).then(
).done();

Ajax

javascriptlettuce.get('/bower.json', function(result){
    equal(result["name"], "lettuce");
    done();
})
javascriptlettuce.post("http://127.0.0.1:5000/some", "something", function(data){
    console.log(data)
})

Single Page Application Example(单页面应用)

1.创建实例

javascriptvar L = new lettuce();

2.定义数据

javascriptvar data = {
    about: "Template",
    what: "This about A Mobile Framework For Romantic",
    why: "Why is a new Framework"
};

3.创建路由函数

javascriptvar 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.添加路由

javascriptL.Router
    .add(/#about/, about)
    .add(/#what/, what)
    .add(/#why/, why)
    .load();

示例

http://valentine.phodal.com/
http://lettuce.phodal.com/

其他

Github: https://github.com/phodal/lettuce

待我代码编成,娶你为妻可好

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值