Skip to content

Commit

Permalink
Closes lift#919. Makes it easier to invoke LiftScreen and Wizard from…
Browse files Browse the repository at this point in the history
… Loc.Snippet params
  • Loading branch information
dpp committed Aug 23, 2011
1 parent 23bfc86 commit f40deb7
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions web/webkit/src/main/scala/net/liftweb/sitemap/Loc.scala
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,17 @@ object Loc {
}

object Snippet {
/**
* Build a Loc.Snippet instance out of a name and a DispatchSnippet (or StatefulSnippet, LiftScreen or Wizard).
* The "render" method will be invoked on the Dispatch snippet
*/
def apply(name: String, snippet: DispatchSnippet): Snippet =
new Snippet(name, ns => snippet.dispatch("render")(ns)) // Issue #919

/**
* Build a Loc.Snippet instance for a given name and a function. Note that the function is call-by-name
* so that it will be created each time it's used. This is useful for CSS Selector Transforms
*/
def apply(name: String, func: => NodeSeq => NodeSeq): Snippet = new Snippet(name, func)
def unapply(in: Snippet): Option[(String, NodeSeq => NodeSeq)] = Some(in.name -> in.func)
}
Expand Down

0 comments on commit f40deb7

Please sign in to comment.