Module: Polaris::UrlHelper
- Defined in:
- app/helpers/polaris/url_helper.rb
Instance Method Summary collapse
- #polaris_button_to(name = nil, options = nil, html_options = nil, &block) ⇒ Object
- #polaris_link_to(name = nil, options = nil, html_options = nil, &block) ⇒ Object
- #polaris_mail_to(email_address, name = nil, html_options = {}, &block) ⇒ Object
Instance Method Details
#polaris_button_to(name = nil, options = nil, html_options = nil, &block) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/helpers/polaris/url_helper.rb', line 3 def (name = nil, = nil, = nil, &block) , = , name if block ||= {} ||= {} [:classes] = [:class] .delete(:class) = Polaris::HeadlessButton.new(submit: true, **) = .with_content(name) unless block content = render(, &block) (, .) do content end end |
#polaris_link_to(name = nil, options = nil, html_options = nil, &block) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/helpers/polaris/url_helper.rb', line 19 def polaris_link_to(name = nil, = nil, = nil, &block) , , name = , name, block if block ||= {} = (, ) [:classes] = [:class] .delete(:class) url = url_target(name, ) link = Polaris::LinkComponent.new(url: url, **) link = link.with_content(name) unless block render(link, &block) end |
#polaris_mail_to(email_address, name = nil, html_options = {}, &block) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/helpers/polaris/url_helper.rb', line 35 def polaris_mail_to(email_address, name = nil, = {}, &block) , name = name, nil if name.is_a?(Hash) = ( || {}).stringify_keys [:classes] = [:class] .delete(:class) extras = %w[cc bcc body subject reply_to].map! { |item| option = .delete(item).presence || next "#{item.dasherize}=#{ERB::Util.url_encode(option)}" }.compact extras = extras.empty? ? "" : "?" + extras.join("&") encoded_email_address = ERB::Util.url_encode(email_address).gsub("%40", "@") url = "mailto:#{encoded_email_address}#{extras}" link = Polaris::LinkComponent.new(url: url, **) link = link.with_content(name || email_address) unless block render(link, &block) end |