Adding the "current" class back to the current menu item

--HG--
branch : dev
This commit is contained in:
Nathan Heskew
2010-10-12 09:04:48 -07:00
parent 7e92ec14e6
commit 766ee10a6c
2 changed files with 21 additions and 11 deletions

View File

@@ -1,17 +1,22 @@
@{
// odd formatting in this file is to cause more attractive results in the output.
var items = (IEnumerable<dynamic>)Enumerable.Cast<dynamic>(Model);
// odd formatting in this file is to cause more attractive results in the output.
var items = (IEnumerable<dynamic>)Enumerable.Cast<dynamic>(Model);
}
@{
if (string.IsNullOrWhiteSpace((string)Model.Text)) {
if (!HasText(Model.Text)) {
@DisplayChildren(Model)
} else {
<li><a href="@Model.Href">@Model.Text</a>
@if (items.Any()) {
if (Model.Href.TrimEnd('/').ToUpperInvariant() == Request.Path.TrimEnd('/').ToUpperInvariant()) {
Model.Classes.Add("current");
}
var tag = Tag(Model, "li");
@tag.StartElement
<a href="@Model.Href">@Model.Text</a>
if (items.Any()) {
<ul>
@DisplayChildren(Model)
</ul>
}
</li>
@tag.EndElement
}
}

View File

@@ -1,17 +1,22 @@
@{
// odd formatting in this file is to cause more attractive results in the output.
var items = (IEnumerable<dynamic>)Enumerable.Cast<dynamic>(Model);
// odd formatting in this file is to cause more attractive results in the output.
var items = (IEnumerable<dynamic>)Enumerable.Cast<dynamic>(Model);
}
@{
if (!HasText(Model.Text)) {
@DisplayChildren(Model)
} else {
<li><a href="@Model.Href">@Model.Text</a>
@if (items.Any()) {
if (Model.Href.TrimEnd('/').ToUpperInvariant() == Request.Path.TrimEnd('/').ToUpperInvariant()) {
Model.Classes.Add("current");
}
var tag = Tag(Model, "li");
@tag.StartElement
<a href="@Model.Href">@Model.Text</a>
if (items.Any()) {
<ul>
@DisplayChildren(Model)
</ul>
}
</li>
@tag.EndElement
}
}