Skip to content

Commit

Permalink
Added active classes to the header.
Browse files Browse the repository at this point in the history
chapter13-6
  • Loading branch information
tmeasday committed Oct 19, 2015
1 parent 9014a07 commit 0696e8a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 3 additions & 3 deletions client/templates/includes/header.html
Expand Up @@ -11,14 +11,14 @@
</div>
<div class="collapse navbar-collapse" id="navigation">
<ul class="nav navbar-nav">
<li>
<li class="{{activeRouteClass 'home' 'newPosts'}}">
<a href="{{pathFor 'newPosts'}}">New</a>
</li>
<li>
<li class="{{activeRouteClass 'bestPosts'}}">
<a href="{{pathFor 'bestPosts'}}">Best</a>
</li>
{{#if currentUser}}
<li>
<li class="{{activeRouteClass 'postSubmit'}}">
<a href="{{pathFor 'postSubmit'}}">Submit Post</a>
</li>
<li class="dropdown">
Expand Down
12 changes: 12 additions & 0 deletions client/templates/includes/header.js
@@ -0,0 +1,12 @@
Template.header.helpers({
activeRouteClass: function(/* route names */) {
var args = Array.prototype.slice.call(arguments, 0);
args.pop();

var active = _.any(args, function(name) {
return Router.current() && Router.current().route.getName() === name
});

return active && 'active';
}
});

0 comments on commit 0696e8a

Please sign in to comment.