Module: Rad::ViewRoutingHelper
- Defined in:
- lib/rad/integration/router/view_routing_helper.rb
Instance Method Summary collapse
Instance Method Details
#link_to(*args, &block) ⇒ Object
links
def link_to *args, &block
# parse args
content = if block
capture(&block)
else
args.shift
end
special = nil
= if args.last.is_a?(Hash)
if args[-2].is_a?(Hash)
args.pop
else
{}
end
else
args << {}
{}
end
# build url
url = special_url(*args) || url_for(*args)
# add javascript
url,
tag :a, content, .merge(href: url)
end
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/rad/integration/router/view_routing_helper.rb', line 37 def link_to *args, &block # content content = if block capture(&block) else args.shift end # url, html_options if args.first.is_a? String args.size.must_be.in 1..2 url, = args ||= {} else if url = special_url(args.first) args.size.must_be <= 2 = args[1] || {} else = if args[-1].is_a?(Hash) and args[-1].is_a?(Hash) args.pop else {} end args << {} unless args[-1].is_a?(Hash) url = url_for(*args) end end # add javascript url, tag :a, content, .merge(href: url) end |