Created
October 25, 2012 21:19
-
-
Save eltimn/3955482 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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