SHtml.memoize: caching templates for AJAX re-rendering
Add facilities to allow caching of snippet templates, such that they are available for subsequent AJAX calls.
This thread contains a discussion:
http://groups.google.com/group/liftweb/browse_thread/thread/78e384c86095ab43?hl=en
In summary: DPP suggested a SHtml.memoize method, that would work something like this:
@DPP: So what will happen is that MemoizedTransform will capture the most recently applied (for the scope of the Request) NodeSeq so in your ajax call, you simply say "applyAgain()" and voila, you get the transform applied to the
memoized view.
This thread contains a discussion:
http://groups.google.com/group/liftweb/browse_thread/thread/78e384c86095ab43?hl=en
In summary: DPP suggested a SHtml.memoize method, that would work something like this:
object MySnip {
def render = SHtml.memoize {"#Foo" #> bar}
}
def memoize(transform: => NodeSeq => NodeSeq): NodeSeq => NodeSeq with MemoizedTransform
trait MemoizedTransform {
/**
* Run the transform again against the most recently passed NodeSeq
*/
def applyAgain(): NodeSeq
}
@DPP: So what will happen is that MemoizedTransform will capture the most recently applied (for the scope of the Request) NodeSeq so in your ajax call, you simply say "applyAgain()" and voila, you get the transform applied to the
memoized view.
Leave a comment