Sha256: 45418b05d637da58ec7d9e9081b2f9fbeaf715f0e4b2eb008fdf9a9547306bf8

Contents?: true

Size: 953 Bytes

Versions: 4

Compression:

Stored size: 953 Bytes

Contents

module Dorsale
  module LinkHelper
    def icon_link_to(icon, name, options = nil, html_options = nil, &block)
      name = "#{icon(icon)} #{name}"
      link_to(name, options, html_options, &block)
    end

    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

    def email_link(text, opts = {})
      return if text.to_s.blank?

      href = "mailto:#{text}"

      link_to(text, href, opts)
    end

    def tel_link(text, opts = {})
      return if text.to_s.blank?

      href = "tel:#{text}"

      link_to(text, href, opts)
    end

    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

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dorsale-1.2.6 app/helpers/dorsale/link_helper.rb
dorsale-1.2.5 app/helpers/dorsale/link_helper.rb
dorsale-1.2.4 app/helpers/dorsale/link_helper.rb
dorsale-1.2.3 app/helpers/dorsale/link_helper.rb