Skip to content

Instantly share code, notes, and snippets.

@frankieroberto
Created May 27, 2010 08:49
Show Gist options
  • Save frankieroberto/415607 to your computer and use it in GitHub Desktop.
Save frankieroberto/415607 to your computer and use it in GitHub Desktop.
navigation_link_to
# A persistant navigation link, as used in "top navs" or "left navs".
# The main difference is that the link is replaced by a <span> tag when
# the link would otherwise lead to the page you're already on. This can be used
# for styling in CSS.
def navigation_link_to(name, options = {}, html_options = {})
if current_page?(options)
content_tag("span", name)
else
link_to name, options, html_options
end
end
# A (persistant) navigation link embedded within a list item.
# === Example
# <%= navigation_list_link_to("Home", root_path) %>
# Produces:
# <li><a href="/">Home</a></li>
def navigation_list_link_to(name, options = {}, html_options = {})
content_tag("li", navigation_link_to(name, options, html_options))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment