class FontAwesomeIcons

TODO deal with other tags like color, etc.

Constants

DEFAULT_ICONS

Public Class Methods

new(tagName, input, tokens) click to toggle source
Calls superclass method
# File lib/jekyll-fa-icons.rb, line 14
def initialize(tagName, input, tokens)
  super
  @input = input
end

Public Instance Methods

render(context) click to toggle source
# File lib/jekyll-fa-icons.rb, line 19
def render(context)
  icon = ""
  # Github is the most used icon for me
  if @input.nil? || @input.empty?
    icon = DEFAULT_ICONS['gh']
  else
    # Font Awesome codes are always 2 words (e.g <i class="fab fa-500px"></i>)
    if @input.split.length < 2
      icon = DEFAULT_ICONS["#{@input.strip}"] #be sure to remove trailing spaces
    else
      icon = @input
    end
  end
  %(<i class="#{icon}"></i>)
end