scala - How Do I Call Snippets From Different Packages In Lift? -
i trying call 1 of 2 snippet methods same name , same class, these snippets located in different packages. here's example code:
snippet 1:
package v1.site.snippet class testsnippet { def test = { println("printed v1") } }
snippet 2:
package v2.site.snippet class testsnippet { def test = { println("printed v2") } }
index.html:
<div class="lift:testsnippet.test"></div>
so how tell index.html testsnippet.test call? both packages have been added in boot.scala.
one option:
liftrules.snippetdispatch.append { case "v1testsnippet" => new v1.site.snippet.testsnippet case "v2testsnippet" => new v2.site.snippet.testsnippet }
your snippets must inherit dispatchsnippet , define def dispatch = { case "test" => test _ }
etc. invoke snippets template v1testsnippet
or v2testsnippet
.
alternatively, like
liftrules.snippets.append { case "v1testsnippet"::"test"::nil => (new v1.site.snippet.testsnippet).test _ case "v2testsnippet"::"test"::nil => (new v2.site.snippet.testsnippet).test _ }
i believe list snippet name in template split on dots.
Comments
Post a Comment