Permalink
Browse files

Merge branch 'master' of github.com:lift/framework

  • Loading branch information...
2 parents dde96de + 2e18c77 commit e460bb96f5bbea4b831f19d975dc1b186df0b41f Joni Freeman committed Dec 13, 2011
@@ -1540,8 +1540,9 @@ class LiftSession(private[http] val _contextPath: String, val uniqueId: String,
first(LiftRules.snippetNamesToSearch.vend(tagName)) {
nameToTry =>
val ret = findSnippetInstance(nameToTry)
- // Update the snippetMap so that we reuse the same instance in this request
- ret.foreach(s => snippetMap.set(snippetMap.is.updated(tagName, s)))
+ // Update the snippetMap so that we reuse the same instance in this request (unless the snippet is transient)
+ ret.filter(TransientSnippet.notTransient(_)).foreach(s => snippetMap.set(snippetMap.is.updated(tagName, s)))
+
ret
}
}
@@ -2241,7 +2242,7 @@ private object SnippetNode {
if (p.pre == "l" || p.pre == "lift") && p.key == "parallel"
=> par = true
- case up: UnprefixedAttribute if up.key == "lift" => // ignore
+ case up: UnprefixedAttribute if up.key == "lift" || up.key == "data-lift" => // ignore
case p: PrefixedAttribute
if p.pre == "lift" && p.key == "snippet"
@@ -168,6 +168,31 @@ trait DispatchSnippet {
}
/**
+ * This trait indicates if the snippet instance should be kept around for the duration of
+ * the Request. There are cases when you don't want a snippet to be kept around.
+ */
+trait TransientSnippet {
+
+ /**
+ * Calculate if this snippet should be treated as transiet.
+ */
+ def transient_? = true
+}
+
+/**
+ * The companion object to the TransientSnippet trait
+ */
+object TransientSnippet {
+ /**
+ * Compute if the instance should be treated as transient
+ */
+ def notTransient(obj: Any): Boolean = obj match {
+ case t: TransientSnippet => !t.transient_?
+ case _ => true
+ }
+}
+
+/**
* Mix this snippet into any snippet. If the snippet is invoked in response to a
* stateless request, then the behavior method is called with the method name of
* the snippet (usually render, but there may be others if you specify a method

0 comments on commit e460bb9

Please sign in to comment.