Skip to content

Instantly share code, notes, and snippets.

@miere
Last active December 17, 2015 12:19
Show Gist options
  • Save miere/5609157 to your computer and use it in GitHub Desktop.
Save miere/5609157 to your computer and use it in GitHub Desktop.
Sample Routes using Layr to render home.xhtml as home resource page ( i.e. "http://example.com/" )
<p>#{pathParam}:#{requestParam}</p
<p xmlns:tpl="urn:layr:template">
<tpl:include when="#{user.isPremiumUser}">
<button class="btn">Premium Panel</button>
</tpl:include>
<tpl:include when="#{user.plan}" equals="BASIC">
<div class="Banner Advertisement"> ... </div>
</tpl:include>
<tpl:include src="hello.xhtml" />
</p>
import layr.routing.api.ResponseBuilder._
import layr.routing.api._
@WebResource("home")
class HomeResource {
@GET
def renderHome():Response =
renderTemplate( "home.xhtml" )
.set("user", new User( true ))
}
case class User (val isPremiumUser:Boolean)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment