Skip to content
moellep edited this page Nov 13, 2014 · 5 revisions

UI.View

Why not use Template Toolkit?

We think TT2's style of templating is inside out. (Same goes for many templating languages: Cold Fusion, ASP, JSP, Velocity, PHP, ...)

Instead of this:

<html>
<head>
<title>[% title %]</title>
</head>
<body>
  <h1>Some Interesting Links</h1>
  <table>
[%  FOREACH link IN link_list %]
    <tr><td><a href="[% link.url %]">[% link.title %]</a></td></tr>
[%  END %]
  </table>
</body>

We would write something more like this:

Page({
    head => Title(['title']),
    body => Join([
        H1('Some Interesting Links'),
        Table(LinkList => [
            Link(['title'], ['url']),
        ]);
    ]),
});

We encapsulate all the html inside a UI.Widget. In this example: Page, Join, H1, Table, and Link.

It's the Widget's responsibility to manage HTML and URI encoding, CVS quoting, ensuring well-formed XML, or correct PDF incantations.

Examples

Clone this wiki locally