class Jekyll::FontAwesomeTag
Public Instance Methods
render(context)
click to toggle source
# File lib/jekyll/font_awesome.rb, line 37 def render(context) if tag_contents = determine_arguments(@markup.strip) icon_class, icon_extra = tag_contents[0], tag_contents[1] icon_tag(icon_class, icon_extra) else raise ArgumentError.new <<-eos Syntax error in tag 'icon' while parsing the following markup: #{@markup} Valid syntax: for icons: {% icon fa-camera-retro %} for icons with size/spin/rotate: {% icon fa-camera-retro fa-lg %} eos end end
Private Instance Methods
determine_arguments(input)
click to toggle source
# File lib/jekyll/font_awesome.rb, line 56 def determine_arguments(input) matched = input.match(/\A(\S+) ?(\S+)?\Z/) [matched[1].to_s.strip, matched[2].to_s.strip] if matched && matched.length >= 3 end
icon_tag(icon_class, icon_extra = nil)
click to toggle source
# File lib/jekyll/font_awesome.rb, line 61 def icon_tag(icon_class, icon_extra = nil) if icon_extra.empty? "<i class=\"fa #{icon_class}\"></i>" else "<i class=\"fa #{icon_class} #{icon_extra}\"></i>" end end