Skip to content

Instantly share code, notes, and snippets.

@jcreamer898
Created December 31, 2013 15:28
Show Gist options
  • Save jcreamer898/8198357 to your computer and use it in GitHub Desktop.
Save jcreamer898/8198357 to your computer and use it in GitHub Desktop.
@{
// Setup the tabs for the profile page.
// The Href will also point to a view located at `MyProfileTabs/HREF.cshtml`.
var tabs = new[]
{
new
{
Href = "tab-profile",
Name = "Profile",
ClassName = "active",
Condition = new Func<bool>(() => true)
},
new
{
Href = "tab-candidate",
Name = "Candidate",
ClassName = "",
Condition = new Func<bool>(() => ViewBag.IsActiveRecruiter != null)
},
new
{
Href = "tab-activity",
Name = "Activity",
ClassName = "",
Condition = new Func<bool>(() => false)
},
new
{
Href = "tab-jobs",
Name = "Jobs",
ClassName = "",
Condition = new Func<bool>(() => false)
}
};
}
<section id="-profile-tabs">
<ul id="-section-tabs" class="nav nav-tabs">
@foreach (var tab in tabs.Where(tab => tab.Condition()))
{
<li class="@tab.ClassName">
<a href="#@tab.Href" data-toggle="tab">@tab.Name</a>
</li>
}
</ul>
</section>
<div class="tab-content">
@foreach (var tab in tabs.Where(tab => ViewExists("MyProfileTabs/" + tab.Href) && tab.Condition()))
{
<div id="@tab.Href" class="tab-pane @tab.ClassName">
@Html.Partial("MyProfileTabs/" + tab.Href, Model)
</div>
}
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment