Class: Tags::IconTag
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- Tags::IconTag
- Defined in:
- app/liquid/tags/icon_tag.rb
Constant Summary collapse
- Syntax =
/(#{::Liquid::QuotedFragment}+)?/
Instance Method Summary collapse
-
#helpers ⇒ Object
Helpers ##.
-
#initialize(tag_name, markup, tokens) ⇒ IconTag
constructor
Init ##.
-
#render(context) ⇒ Object
Output ##.
Constructor Details
#initialize(tag_name, markup, tokens) ⇒ IconTag
Init ##
7 8 9 10 11 12 13 14 15 |
# File 'app/liquid/tags/icon_tag.rb', line 7 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 |
Instance Method Details
#helpers ⇒ Object
Helpers ##
20 21 22 |
# File 'app/liquid/tags/icon_tag.rb', line 20 def helpers @helpers ||= ApplicationController.helpers end |
#render(context) ⇒ Object
Output ##
27 28 29 30 31 32 33 |
# File 'app/liquid/tags/icon_tag.rb', line 27 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 |