Created
May 30, 2014 03:24
-
-
Save pzi/f728782051d03b1bcb02 to your computer and use it in GitHub Desktop.
Active page checker for navigation elements within middleman app
This file contains hidden or 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
helpers do | |
def nav_active(url) | |
if (url.instance_of? String) | |
current_resource.url == url_for(url) ? {class: "active"} : {} | |
elsif (url.instance_of? Array) | |
url.map { |url| url_for(url) }.include?(current_resource.url) ? {class: "active"} : {} | |
else | |
{} | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment