liftweb-uirouter

angularjs ui-router module for scala liftweb framework

git clone https://9o.is/git/liftweb-uirouter.git

SnippetHelper.scala

(1245B)


      1 package net.liftmodules.uirouter
      2 package snippet
      3 
      4 import xml._
      5 import net.liftweb._
      6 import common._
      7 import util._
      8 import Helpers._
      9 
     10 /**
     11  * SnippetHelper from Lift-Extras
     12  * 
     13  * https://github.com/eltimn/lift-extras/blob/master/library/src/main/scala/net/liftmodules/extras/SnippetHelper.scala
     14  */
     15 private[snippet] trait SnippetHelper {
     16 
     17   /**
     18    * Allows for the following to be used when building snippets that return CssSel.
     19    *
     20    * Usage:
     21    *
     22    * for {
     23    * user <- User.currentUser ?~ "You must be logged in to edit your profile."
     24    * } yield ({
     25    * ...
     26    * }): CssSel
     27    */
     28   implicit protected def boxCssSelToCssSel(in: Box[CssSel]): CssSel = in match {
     29     case Full(csssel) => csssel
     30     case Failure(msg, _, _) => "*" #> Text(msg)
     31     case Empty => "*" #> Text("Nothing Found")
     32   }
     33 
     34   /**
     35    * Allows for the following to be used when building snippets that return NodeSeq.
     36    *
     37    * Usage:
     38    *
     39    * for {
     40    * user <- User.currentUser ?~ "You must be logged in to edit your profile."
     41    * } yield ({
     42    * ...
     43    * }): NodeSeq
     44    */
     45   implicit protected def boxNodeSeqToNodeSeq(in: Box[NodeSeq]): NodeSeq = in match {
     46     case Full(ns) => ns
     47     case Failure(msg, _, _) => Text(msg)
     48     case Empty => Text("Nothing Found")
     49   }
     50 }