Created
September 12, 2012 20:45
-
-
Save stoplion/3709781 to your computer and use it in GitHub Desktop.
Needed a method like link_to_unless_current but that takes a block for both failing/passing conditions and either creates a link or not from the block
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
def make_anchor_unless_current(options={}) | |
if current_page?(options) | |
content_tag(:span, class: 'current') do | |
yield | |
end | |
else | |
link_to options do | |
yield | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment