Lettuce 移动框架 for Romantic

Lettuce 移动框架 for Romantic_第1张图片

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("

{%=o.title%}

\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("

{%=o.about%}

", data); return aboutPage.render(templates, "results"); }; var whyPage = function(){ var whyPage = new L.SimpleView(); var templates = L.Template.tmpl("

{%=o.why%}

", data); return whyPage.render(templates, "results"); }; var whatPage = function(){ var whatPage = new L.SimpleView(); var templates = L.Template.tmpl("

{%=o.what%}

", 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

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

你可能感兴趣的:(javascript,框架)