Skip to content

Commit

Permalink
Make last crumb .active and don't render as link, for erichexter#58
Browse files Browse the repository at this point in the history
  • Loading branch information
serra committed Jan 29, 2013
1 parent 0752d74 commit b16f8f9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/Bootstrap/HtmlHelpers/Navigation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,15 @@ private static IHtmlString BuildBreadcrumbTrail(NamedRoute namedRoute, HtmlHelpe
{
var li = new TagBuilder("li");
var routeLink = helper.RouteLink(namedRoute.DisplayName, namedRoute.Name);
li.InnerHtml = string.Format("{0}<span class=\"divider\"> / </span>", routeLink);
if (NavigationViewExtensions.CurrentRouteMatchesName(helper, namedRoute.Name))
{
li.AddCssClass("active");
li.InnerHtml = string.Format("{0}", namedRoute.DisplayName);
}
else
{
li.InnerHtml = string.Format("{0}<span class=\"divider\">/</span>", routeLink);
}
var breadcrumbTrailPart = new HtmlString(li.ToString(TagRenderMode.Normal));
if (namedRoute.Parent == null) return breadcrumbTrailPart;
return new HtmlString(string.Format("{0}{1}", BuildBreadcrumbTrail(namedRoute.Parent, helper), breadcrumbTrailPart));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public static MvcHtmlString NavigationListItemRouteLink(this HtmlHelper html, Na
return MvcHtmlString.Create(li.ToString(TagRenderMode.Normal));
}

static bool CurrentRouteMatchesName(HtmlHelper html, string routeName)
public static bool CurrentRouteMatchesName(HtmlHelper html, string routeName)
{
var namedRoute = html.ViewContext.RouteData.Route as NamedRoute;
if (namedRoute != null)
Expand Down

0 comments on commit b16f8f9

Please sign in to comment.