Lift Web Framework

In addition surrounding XHTML with a template, you can also embed a template at the current point in the page rendering with the <lift:embed/> tag.

I am an example of a template that is embedded!!

The above paragraph was embedded using this code:

    <lift:embed what="/templating/_sample_embed"/>
  

Templates that start with the underscore ('_') or period ('.') characters will not be served directly by Lift, but may be accessed using the surround and embed tags.

Lift will select templates based on the current localization setting for the session. Lift uses the function in LiftRules.localeCalculator to determine the current locale for template selection. By default the function is:

  def defaultLocaleCalculator(request: Box[HttpServletRequest]) = 
    request.flatMap(_.getLocale() match 
                    {case null => Empty 
                     case l: Locale => Full(l)}).openOr(Locale.getDefault())
But you can customize the function to return the locale of the currently logged in user, detect the IP address of the request, etc.

Based on the locale, Lift will look for templates based on the base template name, in this case '/templating/_sample_embed' and then append an underscore ('_') followed by the complete locale, for example 'en_US'. So, Lift will look for '/templating/_sample_embed_en_US.html'. If that resource is not available, Lift will look for '/templating/_sample_embed_en.html' and finally '/templating/_sample_embed.html'.


Lift is Copyright 2007-2010 WorldWide Conferencing, LLC. Distributed under an Apache 2.0 License.
Lift version 2.3 built on Tue Apr 05 13:24:00 PDT 2011.
Stats: Total Memory: 477,233,152 Free Memory: 410,760,248 Open Sessions: 127
Updated At: Sat Feb 04 11:05:54 PST 2012 Started At: Thu Jul 07 11:17:57 PDT 2011