Skip to content
A web framework based on the widget tree concept, written in Clojure
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



Lemontree is a web framework based on the widget tree concept. It is
largely inspired by Weblocks weblocks
and borrows many of its concepts.

Existing web programming frameworks are either too simplistic or too
complex. On one side of the spectrum there is PHP and applications which
are composed of web pages with embedded code. The problem with this
approach is that it doesn’t scale to complex applications and forces
programmers into a simplistic design mindset. Resulting applications are
composed of web pages with create, read, update, or delete
functionality. AJAX is treated as a way to accelerate some of these

On the other side of the spectrum there is the Enterprise Java
monster. While it does decouple page generation from the application
model, it is large and unnecessarily complex. A large part of this
complexity is due to the limitations of the language.

The guiding principle behind the design of Lemontree is best explained
by a quote:

“A sentence should contain no unnecessary words, a paragraph no
unnecessary sentences, for the same reason that a drawing should have no
unnecessary lines and a machine no unnecessary parts. This requires not
that the writer make all sentences short, or avoid all detail and treat
all subjects only in outline, but that every word tell.” (Strunk and
White, “The Elements of Style”, fourth edition)

Basic assumptions and goals

  • Based on a widget tree concept — applications are composed of
    widgets that may be rendered.
  • Actions (rendered as links) modify the widget tree. Updated widgets
    are rendered and sent to the client either as JSON (AJAX) or full-page
  • Based on the Yahoo User Interface Library (YUI) version 3, using also
    YUI2 widgets until YUI3 is complete.
  • Most functionality (within reason) degrades gracefully if Javascript
    isn’t available.

Lemontree uses the excellent Ring library for underlying HTTP

Is Lemontree a good choice for me?

  • If you’re looking for a way to quickly throw together a simple website
    with a form or two, then Lemontree probably isn’t the right choice.
  • If you want to work with full-page templates where only small details
    are to be provided by the application, then Lemontree probably isn’t
    the right choice.
  • If you want to support a legacy URI-routing scheme with overlapping
    URIs and convoluted logic, then Lemontree probably isn’t the right
  • On the other hand, if you need to design modern AJAXy web applications
    with complex logic and have them be small and maintainable, then
    Lemontree should be just right for you.

Widget tree model

In Lemontree all web pages are generated from a widget tree. Think of
widgets as corresponding to (large) subtrees of the DOM. Each web page
contains a root widget which in turn contains children widgets. During
rendering, these are serialized to HTML and form the complete web page.

URI routing is implemented by matching paths in the tree. For every
request the URI is split into ‘uri-tokens’ (path elements that are
normally separated by slashes) into a list of tokens. Each widget (tree
element) may have a :path attribute. If that attribute is set, the
widget will only be considered for a given request if the current URI
token matches the :path attribute. Think of it as selecting subtrees
in your full widget tree based on the URI.

Once a token is matched, it is moved to the consumed-tokens stack, so
that widgets down the tree do not see it anymore and are free to
consider subsequent tokens in the token list.

Why YUI?

There are many JavaScript libraries out there. Yes, jQuery is the
coolest kid on the block today and all the cool kids use
jQuery, Prototype is great too and Ruby on Rails uses Prototype… The
list goes on.

Lemontree uses YUI for the following reasons:

  • YUI has excellent documentation
  • It is developed by a paid (commercial) team with contributors
  • It is rigorously tested on a variety of major browsers on various
    operating systems (forming a browser matrix)
  • There is a rich choice of widgets, so you can build applications using
    only YUI, with very few additional libraries

There are no plans to use any other foundation Javascript libraries in
Lemontree and no plans to provide a “compatibility layer” so that many
libraries can be supported.

Why PostgreSQL?

It’s good, it’s free, it has all the features you might possibly want
from a relational database.

There are no plans to support other relational databases. It seriously
isn’t worth the effort.

Something went wrong with that request. Please try again.