Skip to content

Instantly share code, notes, and snippets.

@pzi
Created May 30, 2014 03:24
Show Gist options
  • Save pzi/f728782051d03b1bcb02 to your computer and use it in GitHub Desktop.
Save pzi/f728782051d03b1bcb02 to your computer and use it in GitHub Desktop.
Active page checker for navigation elements within middleman app
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