Skip to content

Commit

Permalink
Fixed SHtml.memoize to not be wacky
Browse files Browse the repository at this point in the history
  • Loading branch information
dpp committed Aug 26, 2011
1 parent 547f044 commit c16413f
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions web/webkit/src/main/scala/net/liftweb/http/SHtml.scala
Expand Up @@ -282,17 +282,15 @@ trait SHtml {
* explicitly capture the template
*/
def memoize(f: => NodeSeq => NodeSeq): MemoizeTransform = {
val salt = (new Exception()).getStackTrace().apply(2).toString
new MemoizeTransform {
object latestNodeSeq extends RequestVar[NodeSeq](NodeSeq.Empty) {
override val __nameSalt = salt
}
def apply(ns: NodeSeq): NodeSeq = {
latestNodeSeq.set(ns)
private var lastNodeSeq: NodeSeq = NodeSeq.Empty

def apply(ns: NodeSeq): NodeSeq = {
lastNodeSeq = ns
f(ns)
}

def applyAgain(): NodeSeq = f(latestNodeSeq.get)
def applyAgain(): NodeSeq = f(lastNodeSeq)
}
}

Expand Down

0 comments on commit c16413f

Please sign in to comment.