Sha256: cde51d82611d10426e44597180d583fb7f2a702a8dc5948f500137a0f640352f

Contents?: true

Size: 1.62 KB

Versions: 1

Compression:

Stored size: 1.62 KB

Contents

module Less
  module Rails
    module Fontawesome
      module LinkHelper
        def fa_link_to(*args, &block)
          if block_given?
            icon = args[0]
            options = args[1] || {}
            html_options = args[2]
            fa_link_to(icon, capture(&block), options, html_options)
          else
            icon = args[0]
            name = args[1]
            options = args[2] || {}
            html_options = args[3]

            html_options = convert_options_to_data_attributes(options, html_options)
            url = url_for(options)

            href = html_options['href']
            tag_options = tag_options(html_options)

            href_attr = "href=\"#{ERB::Util.html_escape(url)}\"" unless href
            "<a #{href_attr}#{tag_options}><i class=\"fa fa-#{icon}\"></i> #{ERB::Util.html_escape(name || url)}</a>".html_safe
          end
        end

        # TODO:

        # def fa_link_to_unless
        #   if condition
        #     if block_given?
        #       block.arity <= 1 ? capture(name, &block) : capture(name, options, html_options, &block)
        #     else
        #       name
        #     end
        #   else
        #     fa_link_to(name, options, html_options)
        #   end
        # end

        # def fa_link_to_if(condition, name, options = {}, html_options = {}, &block)
        #   fa_link_to_unless !condition, name, options, html_options, &block
        # end

        # def fa_link_to_unless_current(name, options = {}, html_options = {}, &block)
        #   fa_link_to_unless current_page?(options), name, options, html_options, &block
        # end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
less-rails-fontawesome-0.8.0 lib/less/rails/fontawesome/link_helper.rb