Created
April 6, 2015 11:22
-
-
Save caulfield/e38ca10acbe4c3d88c00 to your computer and use it in GitHub Desktop.
rails link_to_if with options
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
module LinkHelpers | |
# wrap condition falsy text into span with html options | |
def link_to_if_with_options(condition, name, options={}, html_options={}, &block) | |
_super = link_to_if condition, name, options, html_options, &block | |
if condition | |
_super | |
else | |
content_tag :span, _super, html_options | |
end | |
end | |
# @see #link_to_if_with_options | |
def link_to_unless_with_options(condition, name, options={}, html_options={}, &block) | |
link_to_if_with_options !condition, name, options, html_options, &block | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment