Module: Flatrack::View::LinkHelper
Overview
View helpers to render link tags
Constant Summary
Constants included from TagHelper
TagHelper::BOOLEAN_ATTRIBUTES, TagHelper::PRE_CONTENT_STRINGS
Instance Method Summary collapse
-
#link_to(*args, &block) ⇒ Object
Creates an HTML link tag.
Methods included from TagHelper
#html_tag, #image_tag, #javascript_tag, #stylesheet_tag
Instance Method Details
#link_to(href, options = {}) ⇒ String #link_to(content, href, options = {}) ⇒ String #link_to(href, options = {}) { ... } ⇒ String
Creates an HTML link tag
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/flatrack/view/link_helper.rb', line 33 def link_to(*args, &block) href, , block = (*args, &block) if href.start_with?('/') && !href.start_with?('//') && mount_path != '/' href = File.join '', mount_path, href end tag_opts = (href, || {}) if current_path == tag_opts[:href] ((tag_opts[:class] ||= '') << ' active').strip! end html_tag(:a, tag_opts, false, &block) end |