Created
May 27, 2010 08:49
-
-
Save frankieroberto/415607 to your computer and use it in GitHub Desktop.
navigation_link_to
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
# 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