Created
September 9, 2013 18:59
-
-
Save wejrowski/6499960 to your computer and use it in GitHub Desktop.
link_wrap_if
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
# Wrap given block with link if.. | |
def link_wrap_if(apply_link, url, opts={}, &block) | |
if apply_link | |
link_to capture(&block), url, opts | |
else | |
capture(&block) | |
end | |
end | |
# link_to_if would only work if you captured the entire block into | |
# a variable then called link_to_if and put that in as the name paramerter | |
# http://apidock.com/rails/ActionView/Helpers/UrlHelper/link_to_if |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment