Sha256: feea754d07bf39a230ff3a1c0d8d07902b127bcf3beb082b85f99e1a2935efb1

Contents?: true

Size: 821 Bytes

Versions: 9

Compression:

Stored size: 821 Bytes

Contents

class Tags::IconTag < Liquid::Tag
  Syntax = /(#{::Liquid::QuotedFragment}+)?/

  #################################

    ## Init ##
    def initialize tag_name, markup, tokens
      if markup =~ Syntax
        @icon = $1.gsub('\'', '')
      else
        raise ::Liquid::SyntaxError.new("Syntax Error in 'Icon Tag' - Valid syntax: {% i <args> %}")
      end

      super
    end

  #################################

    ## Helpers ##
    def helpers
      @helpers ||= ApplicationController.helpers
    end

  #################################

    ## Output ##
    def render context
      gem_name = 'font-awesome-rails'
      gdep = Gem::Dependency.new gem_name

      # Invoke
      helpers.send (gdep.matching_specs.max_by(&:version) ? :fa_icon : :ion_icon), @icon
    end

  #################################

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
fl-0.3.9 app/liquid/tags/icon_tag.rb
fl-0.3.8 app/liquid/tags/icon_tag.rb
fl-0.3.6 app/liquid/tags/icon_tag.rb
fl-0.3.5 app/liquid/tags/icon_tag.rb
fl-0.3.4 app/liquid/tags/icon_tag.rb
fl-0.3.3 app/liquid/tags/icon_tag.rb
fl-0.3.2 app/liquid/tags/icon_tag.rb
fl-0.3.1 app/liquid/tags/icon_tag.rb
fl-0.3.0 app/liquid/tags/icon_tag.rb