Up: Chapter 23

23.1 Snippet Resolution

Lift snippets transform markup to dynamic content. The are functions that transform NodeSeq => NodeSeq.
Snippets can be invoked from templates via tags:
<lift:surround with="default" at="content">
  <p>
    You have reached this page, but you can only get here if you’ve logged in
    first.
  </p>
</lift:surround>
or via class attributes.
<p class="lift:surround?with=default;at=content">
  You have reached this page, but you can only get here if you’ve logged in
  first.
</p>
In both cases, the surround (See ) snippet will be invoked with attribute with set to default and at set to content. The parameter passed to the surround NodeSeq => NodeSeq function is:
<p>
  You have reached this page, but you can only get here if you’ve logged in
  first.
</p>
Lift will resolve from the snippet name to a function in the following steps.

23.1.1LiftSession.liftTagProcessing

Lift consults a List[PartialFunction[(String, Elem, MetaData, NodeSeq, String), NodeSeq]] located in LiftSession.liftTagProcessing for the rules to use to evaluate the snippet name, attributes, etc. into the resulting NodeSeq. LiftSession.liftTagProcessing is the result of LiftRules.liftTagProcessing or else the default Lift tag processor. If you need special snippet resolution mechanisms, you can place them in LiftRules.liftTagProcessing. By default, the snippets get processed by LiftSession.processSnippet.

23.1.2LiftRules.liftTagProcessing

LiftRules.liftTagProcessing looks for the form attribute and sets the isForm variable. Next, Lift determines if the contents of the snippet should be evaluated eagerly by looking for one of eager_eval, l:eager_eval, or lift:eager_eval attributes.
If the snippet is an eager evaluation, the child tags will be evaluated for any snippets.
Either the originally passed children or the eagerly evaluated children will be referred to as children in the next section.

23.1.3 Snippet name resolution

Lift looks for the named snippet in the following locations in order:

23.1.4 Post-processing of results

parallel snippets
Up: Chapter 23

(C) 2012 David Pollak