Skip to content

Instantly share code, notes, and snippets.

@eltimn
Created October 25, 2012 21:19
Show Gist options
  • Save eltimn/3955482 to your computer and use it in GitHub Desktop.
Save eltimn/3955482 to your computer and use it in GitHub Desktop.
trait GroupMenu extends SnippetHelpers {
def itemHtml: NodeSeq
def itemActiveHtml: NodeSeq
def outerHtml: NodeSeq
def render(in: NodeSeq): NodeSeq = {
for {
group <- S.attr("group") ?~ "Group not specified"
sitemap <- LiftRules.siteMap ?~ "Sitemap is empty"
request <- S.request ?~ "Request is empty"
curLoc <- request.location ?~ "Current location is empty"
} yield {
val ns: NodeSeq = sitemap.locForGroup(group) flatMap { loc =>
val itemCssSel = "* *" #> SiteMap.buildLink(loc.name)
if (curLoc.name == loc.name)
itemCssSel.apply(itemActiveHtml)
else
itemCssSel.apply(itemHtml)
}
("* *" #> ns).apply(outerHtml)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment