Created
November 3, 2012 22:38
-
-
Save arashi01/4009155 to your computer and use it in GitHub Desktop.
bootstrap lift (see https://groups.google.com/forum/?fromgroups=#!topic/liftweb/MCYjx-Dg4MQ)
This file contains 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
package riff.raff.snippet | |
import net.liftweb.http._ | |
import xml.NodeSeq | |
import net.liftweb.sitemap.MenuItem | |
class BootstrapMenu { | |
def render(in: NodeSeq): NodeSeq = { | |
val menuEntries = | |
(for {sm <- LiftRules.siteMap; req <- S.request} yield sm.buildMenu(req.location).lines) openOr Nil | |
<ul class="nav"> | |
{ | |
for (item <- menuEntries) yield { | |
var styles = item.cssClass openOr "" | |
if (item.current) styles += " active" | |
item.kids match { | |
case Nil => | |
<li class={styles}><a href={item.uri}>{item.text}</a></li> | |
case kids => | |
<li class={styles + " dropdown"}> | |
<a href="#" class="dropdown-toggle">{item.text}</a> | |
<ul class="dropdown-menu"> | |
{ | |
for (kid <- kids) yield { | |
<li><a href={kid.uri}>{kid.text}</a></li> | |
} | |
} | |
</ul> | |
</li> | |
} | |
} | |
} | |
</ul> | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment