Class: JekyllTagPlugin::MyTag

Inherits:
JekyllSupport::JekyllTag
  • Object
show all
Includes:
JekyllPluginTemplateVersion
Defined in:
lib/jekyll_tag_plugin.rb

Overview

This class implements the Jekyll tag functionality

Constant Summary collapse

@@emojis =
{
  'angry'      => '😠',
  'boom'       => '💥', # used when requested emoji is not recognized
  'grin'       => '😀',
  'horns'      => '😈',
  'kiss'       => '😙',
  'open'       => '😃',
  'poop'       => '💩',
  'sad'        => '😢',
  'scream'     => '😱',
  'smiley'     => '😁', # default emoji
  'smirk'      => '😏',
  'two_hearts' => '💕',
}.sort_by { |k, _v| [k] }.to_h

Constants included from JekyllPluginTemplateVersion

JekyllPluginTemplateVersion::VERSION

Instance Method Summary collapse

Instance Method Details

#render_implvoid

This method returns an undefined value.

Parameters:

  • tag_name (String)

    is the name of the tag, which we already know.

  • argument_string (String)

    the arguments from the web page.

  • tokens (Liquid::ParseContext)

    tokenized command line



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/jekyll_tag_plugin.rb', line 48

def render_impl
  @emoji_name     = @helper.parameter_specified?('name')  || 'smiley' # Ignored if `list` is specified
  @emoji_align    = @helper.parameter_specified?('align') || 'inline' # Allowable values are: inline, right or left
  @emoji_size     = @helper.parameter_specified?('size')  || '3em'
  @emoji_and_name = @helper.parameter_specified?('emoji_and_name')
  @list           = @helper.parameter_specified?('list')
  @emoji_hex_code = @@emojis[@emoji_name] if @emoji_name || @@emojis['boom']

  # variables defined in pages are stored as hash values in liquid_context
  # _assigned_page_variable = @liquid_context['assigned_page_variable']

  @layout_hash = @page['layout']

  @logger.debug do
    <<~HEREDOC
      liquid_context.scopes=#{@liquid_context.scopes}
      mode="#{@mode}"
      page attributes:
        #{@page.sort
               .reject { |k, _| REJECTED_ATTRIBUTES.include? k }
               .map { |k, v| "#{k}=#{v}" }
               .join("\n  ")}
    HEREDOC
  end

  # Return the value of this Jekyll tag
  if @list
    list
  else
    assemble_emoji(@emoji_name, @emoji_hex_code)
  end
end