## lift's approach to dynamic content

lift 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, lift looks for a class named "Bar" in a number of packages. If the class isn't found, lift 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 or programmers to maintain the files.

lift processes a number of special tags:

- `<lift:surround>` -- surround the XHTML with a template. This allows a site-wide template to be used, but individual pages to have different contents. Multiple `surround` tags can be used within a single document.
- `<lift:embed>` -- embed a template in the XHTML.
- `<lift:comet>` -- 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.
- `<lift:snippet>` -- create a short-lived "snippet" (kind of like a Rails controller) and insert the output of the snippet into the page.

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.

The code to embed the AJAX clock on the page is:

    <lift:comet type="Clock">Current Time:
    <clk:time>Missing Clock</clk:time></lift:comet>

The Clock comet widget is:

      def render = bind("time" -> Text(timeNow.toString))

Which binds a string containing the current time to the "time" part of the XHTML and returns this as XHTML.