/
simple.html
91 lines (82 loc) · 3.35 KB
/
simple.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<lift:surround with="default" at="content">
<h2><i>Lift</i>'s approach to dynamic content</h2>
<p>
<i>Lift</i> has a "view first" rendering strategy. When a
request comes in, an appropriate XHTML page is selected to
satisfy the request. If there is a file in the path
that matches the name (e.g., '/foo/bar.html'), that file
is used. If there's no matching file, <i>lift</i>
looks for a class named "Bar" in a number of packages.
If the class isn't found, <i>Lift</i> looks for foo.Bar
in a number of packages. Once the rendering class is located,
an instance is created and the "render" method is called. This allows
HTML designers <b>or</b> programmers to maintain the files.
</p>
<p><i>Lift</i> processes a number of special tags:
<ul>
<li><code><lift:surround></code> -- surround the XHTML with
a template. This allows a site-wide template to be used, but
individual pages to have different contents. Multiple <code>surround</code>
tags can be used within a single document.</li>
<li><code><lift:embed></code> -- embed a template in the XHTML.</li>
<li><code><lift:comet></code> -- Insert the rendered output of
a long-lived comet widget. Also, the comet widget can notify a page that
content has changed and the next time the page services an AJAX request,
it will update the comet widget's content in the browser.
Comet widgets are handed "recommended" XHTML that they can "bind"
to. This is Wicket's and TurboGears' approach.
A comet widget may also choose to ignore the recommendation
and render its own XHTML.</li>
<li><code><lift:snippet></code> -- create a
short-lived "snippet" (kind of like a Rails controller) and insert
the output of the snippet into the page.</li>
</ul></p>
<p>Once a page has composed its XHTML by getting renderings from each of
widgets, links on the page are adjusted to the context page
of the request. Additionally, if AJAX is enabled, forms marked
as AJAX ready are re-written to use AJAX.</p>
<p>The code to embed the AJAX clock on the page is:</p>
<style type="text/css">
<!--
.function-name {
/* font-lock-function-name-face */
color: #87ceeb;
}
.string {
/* font-lock-string-face */
color: #32cd32;
}
-->
</style>
<pre>
<<span class="function-name">lift:comet</span> type=<span class="string">"Clock"</span>>Current Time:
<<span class="function-name">clk:time</span>>Missing Clock<<span class="function-name">/clk:time</span>><<span class="function-name">/lift:comet</span>>
</pre>
<p>The Clock comet widget is:</p>
<style type="text/css">
<!--
.function-name {
/* font-lock-function-name-face */
color: #87ceeb;
}
.keyword {
/* font-lock-keyword-face */
color: #6495ed;
font-weight: bold;
}
.string {
/* font-lock-string-face */
color: #32cd32;
}
.variable-name {
/* font-lock-variable-name-face */
color: #98fb98;
}
-->
</style>
<pre>
<span class="keyword">def</span> <span class="function-name">render</span> = bind(<span class="string">"time"</span> -> Text(<span class="keyword">timeNow</span>.toString))
</pre>
<p>Which binds a string containing the current time to the "time" part
of the XHTML and returns this as XHTML.</p>
</lift:surround>