Mobile Framework: Lettuce, a simple but not simple mobile development framework

Mobile Framework: Lettuce, a simple but not simple mobile development framework

Lettuce is a small and powerful mobile development framework.

Online demo: http://phodal.github.io/lettuce.

Example

1. Create a new instance

  1. var L = new lettuce();

2. Define the data

  1. var data = {
  2. about: "Template" ,
  3. what: "This about A Mobile Framework For Romantic" ,
  4. why: "Why is a new Framework"  
  5. };

3. Create router function

  1. function about() {
  2. var result = L.tmpl( "<h3>{%=o.about%}</h3>" , data);
  3. document.getElementById( "results" ).innerHTML = result;
  4. };
  5.  
  6. function what() {
  7. var result = L.tmpl( "<h3>{%=o.what%}</h3>" , data);
  8. document.getElementById( "results" ).innerHTML = result;
  9. }
  10.  
  11. function why() {
  12. var result = L.tmpl( "<h3>{%=o.why%}</h3>" , data);
  13. document.getElementById( "results" ).innerHTML = result;
  14. }

4. Add a router

  1. L.Router
  2. .add(/#about/, about)
  3. .add(/#what/, what)
  4. .add(/#why/, why)
  5. .load();

process

Done

  • Template
  • Router
  • Ajax
  • Class
  • Promises
  • Event

On Going

  • Model

Simple View

  1. var pageView = function(){};
  2. pageView.prototype = {
  3. init:function(){
  4. var result = L.tmpl( "<h3>" + this .message + "</h3>" , data);
  5. document.getElementById( "results" ).innerHTML = result;
  6. }
  7. };
  8.  
  9. var about = new L.Class(pageView);
  10. about.prototype.message = data.about;
  11.  
  12. var what = new L.Class(pageView);
  13. what.prototype.message = data.what;
  14.  
  15. var why = new L.Class(pageView);
  16. why.prototype.message = data.why;

license

This code is released under the MIT license. See license.txt in this directory .

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

© 2015 Phodal Huang.

<<:  WeChat opens 11 types of interfaces: developers can build real web applications based on WeChat

>>:  Three options for developing mobile apps: native, HTML5, or hybrid

Recommend

Trillion-dollar market value? Don’t forget Apple’s fatal weakness

At present, the release of iPhone 6 has attracted...

How to quickly attract “new customers” and “new fans”?

Time is money, so relying solely on long-termism ...

Zhihu Promotion and Traffic Draining Strategy

Today I will share with you a low-cost, high-retu...

10 communication principles that advertisers must know!

The essence of advertising is communication. This...

Is this heart-pounding feeling a disease?

Have you ever experienced this? Late at night, si...

How does exercise make people feel comfortable and relaxed?

《Cotton Swab Medical Science Popularization》 Peki...

Hprose for Node.js 1.6.0 released

Hprose is an advanced lightweight cross-language ...

Why are children easily addicted to playing games but not to studying?

Recently, a shocking news spread on Weibo that so...

What is the price of the best silicone dolls?

As a companion, silicone dolls can accompany you ...

There are no rockets or launch towers on the moon, so how do astronauts return?

It has been decades since the first successful ma...

KOC Creation Guide

Recently, the operation circle has been talking a...

Hangui Speculation Research Institute 2021 "Turtle Project 2.0" video + document

Introduction to the video + document resources of...