Skip to content

Instantly share code, notes, and snippets.

@wejrowski
Created September 9, 2013 18:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wejrowski/6499960 to your computer and use it in GitHub Desktop.
Save wejrowski/6499960 to your computer and use it in GitHub Desktop.
link_wrap_if
# 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