Skip to content

Instantly share code, notes, and snippets.

@mischa
Created December 20, 2008 13:40
Show Gist options
  • Save mischa/38320 to your computer and use it in GitHub Desktop.
Save mischa/38320 to your computer and use it in GitHub Desktop.
def link_to(*args, &block)
if block_given?
options = args.first || {}
html_options = args.second
concat(link_to(capture(&block), options, html_options))
else
name = args.first
options = args.second || {}
html_options = args.third
url = url_for(options)
if html_options
html_options = html_options.stringify_keys
href = html_options['href']
convert_options_to_javascript!(html_options, url)
tag_options = tag_options(html_options)
else
tag_options = nil
end
href_attr = "href=\"#{url}\"" unless href
"<a #{href_attr}#{tag_options}>#{name || url}</a>"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment