Created
April 8, 2014 21:35
-
-
Save alexcheng1982/10196385 to your computer and use it in GitHub Desktop.
Jekyll - Bootstrap Navbar Active Status for Different Pages See http://midgetontoes.com/blog/2014/04/09/jekyll-bootstrap-navbar-active-status-for-different-pages/
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
module SampleApp | |
class ActivePageTag < Liquid::Tag | |
def initialize(tag_name, text, tokens) | |
super | |
@text = text | |
end | |
def render(context) | |
name = context.environments.first["page"]["name"] | |
return '' if name.nil? or @text.nil? | |
return name == @text ? ' active ' : '' | |
end | |
end | |
end | |
Liquid::Template.register_tag('active_page', SampleApp::ActivePageTag) |
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
--- | |
layout: page | |
title: Contact us | |
name: contact | |
--- | |
Contact us |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment