Module: Dorsale::LinkHelper
- Included in:
- AllHelpers
- Defined in:
- app/helpers/dorsale/link_helper.rb
Instance Method Summary collapse
- #email_link(text, opts = {}) ⇒ Object
- #icon_link_to(icon, name, options = nil, html_options = nil, &block) ⇒ Object
- #tel_link(text, opts = {}) ⇒ Object
- #twitter_link(text, opts = {}) ⇒ Object
- #web_link(text, opts = {}) ⇒ Object
Instance Method Details
#email_link(text, opts = {}) ⇒ Object
16 17 18 19 20 21 22 |
# File 'app/helpers/dorsale/link_helper.rb', line 16 def email_link(text, opts = {}) return if text.to_s.blank? href = "mailto:#{text}" link_to(text, href, opts) end |
#icon_link_to(icon, name, options = nil, html_options = nil, &block) ⇒ Object
2 3 4 5 |
# File 'app/helpers/dorsale/link_helper.rb', line 2 def icon_link_to(icon, name, = nil, = nil, &block) name = "#{icon(icon)} #{name}".html_safe link_to(name, , , &block) end |
#tel_link(text, opts = {}) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'app/helpers/dorsale/link_helper.rb', line 24 def tel_link(text, opts = {}) return if text.to_s.blank? value = text.gsub(" ", "") href = "tel:#{value}" link_to(text, href, opts) end |
#twitter_link(text, opts = {}) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'app/helpers/dorsale/link_helper.rb', line 33 def twitter_link(text, opts = {}) return if text.to_s.blank? href = text href = "https://twitter.com/#{text}" unless text.include?("twitter.com") href = "https://#{text}" unless href.include?("://") link_to(text, href, opts) end |
#web_link(text, opts = {}) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'app/helpers/dorsale/link_helper.rb', line 7 def web_link(text, opts = {}) return if text.to_s.blank? href = text href = "http://#{text}" unless text.include?("://") link_to(text, href, opts) end |