Permalink
Browse files

Misc code cleanup

  • Loading branch information...
1 parent b8eb1d0 commit 4f9d7a2f156b35e1911036b6f6c81b306e87b431 @dpp dpp committed Mar 10, 2011
@@ -20,6 +20,7 @@ package snippet
import scala.xml._
import net.liftweb.http._
+import net.liftweb.common._
/**
* The Loc snippet is used to render localized content.
@@ -64,8 +65,8 @@ object Loc extends DispatchSnippet {
def render(locId: String, kids: NodeSeq) : NodeSeq = {
S.loc(locId) openOr
- (S.attr.~("locid").map(_.text) match {
- case Some(id) => S.loc(id, kids)
+ (S.attr("locid") match {
+ case Full(id) => S.loc(id, kids)
case _ => S.loc(kids.text, kids)
})
}
@@ -32,14 +32,16 @@ object Surround extends DispatchSnippet {
}
def render(kids: NodeSeq) : NodeSeq =
- (for {ctx <- S.session ?~ ("FIX"+"ME: Invalid session")
- req <- S.request ?~ ("FIX"+"ME: Invalid request")
- } yield {
- val mainParam = (S.attr.~("at").map(_.text).
- getOrElse("main"), ctx.processSurroundAndInclude(PageName.get, kids))
- val paramsMap = WithParamVar.get + mainParam
- ctx.findAndMerge(S.attr.~("with"), paramsMap)
- }) match {
+ (for {
+ ctx <- S.session ?~ ("FIX"+"ME: Invalid session")
+ req <- S.request ?~ ("FIX"+"ME: Invalid request")
+ } yield {
+ WithParamVar.doWith(Map()) {
+ val mainParam = (S.attr("at") openOr "main", ctx.processSurroundAndInclude(PageName.get, kids))
+ val paramsMap = WithParamVar.get + mainParam
+ ctx.findAndMerge(S.attr("with"), paramsMap)
+ }
+ }) match {
case Full(x) => x
case Empty => Comment("FIX"+ "ME: session or request are invalid")
case Failure(msg, _, _) => Comment(msg)
@@ -32,11 +32,13 @@ object WithParam extends DispatchSnippet {
}
def render(kids: NodeSeq) : NodeSeq = {
- (for {ctx <- S.session ?~ ("FIX"+"ME: Invalid session")
- req <- S.request ?~ ("FIX"+"ME: Invalid request")
+ (for {
+ ctx <- S.session ?~ ("FIX"+"ME: Invalid session")
+ req <- S.request ?~ ("FIX"+"ME: Invalid request")
} yield {
- val name = S.attr.~("name").map(_.text).getOrElse("main")
- WithParamVar(WithParamVar.get + (name -> ctx.processSurroundAndInclude(PageName.get, kids)))
+ val name: String = S.attr("name") openOr "main"
+ val body = ctx.processSurroundAndInclude(PageName.get, kids)
+ WithParamVar.atomicUpdate(_ + (name -> body))
NodeSeq.Empty
}) match {
case Full(x) => x
@@ -1997,8 +1997,8 @@ class LiftSession(private[http] val _contextPath: String, val uniqueId: String,
}
</body> </html>
- private[liftweb] def findAndMerge(templateName: Box[Seq[Node]], atWhat: Map[String, NodeSeq]): NodeSeq = {
- val name = templateName.map(s => if (s.text.startsWith("/")) s.text else "/" + s.text).openOr("/templates-hidden/default")
+ private[liftweb] def findAndMerge(templateName: Box[String], atWhat: Map[String, NodeSeq]): NodeSeq = {
+ val name: String = templateName.map(s => if (s.startsWith("/")) s else "/" + s).openOr("/templates-hidden/default")
def hasLiftBind(s: NodeSeq): Boolean =
(Helpers.findOption(s) {

0 comments on commit 4f9d7a2

Please sign in to comment.