Class: JekyllBlockTagPlugin::MyBlock

Inherits:
JekyllSupport::JekyllBlock
  • Object
show all
Includes:
JekyllPluginTemplateVersion
Defined in:
lib/jekyll_block_tag_plugin.rb

Overview

This class implements the Jekyll block tag functionality

Constant Summary collapse

REJECTED_ATTRIBUTES =
%w[content excerpt next previous].freeze

Constants included from JekyllPluginTemplateVersion

JekyllPluginTemplateVersion::VERSION

Instance Method Summary collapse

Instance Method Details

#render_impl(content) ⇒ String

Method prescribed by the Jekyll support plugin.

Returns:

  • (String)


30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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
# File 'lib/jekyll_block_tag_plugin.rb', line 30

def render_impl(content)
  @helper.gem_file __FILE__ # This enables attribution

  @param1  = @helper.keys_values['param1'] # Obtain the value of parameter param1
  @param2  = @helper.keys_values['param2']
  @param3  = @helper.keys_values['param3']
  @param4  = @helper.keys_values['param4']
  @param5  = @helper.keys_values['param5']
  @param_x = @helper.keys_values['not_present'] # The value of parameters that are present is nil, but displays as the empty string

  @logger.debug do
    "      tag_name = '\#{@helper.tag_name}'\n      argument_string = '\#{@helper.argument_string}'\n      @param1 = '\#{@param1}'\n      @param2 = '\#{@param2}'\n      @param3 = '\#{@param3}'\n      @param4 = '\#{@param4}'\n      @param5 = '\#{@param5}'\n      @param_x = '\#{@param_x}'\n      params =\n        \#{@helper.keys_values.map { |k, v| \"\#{k} = \#{v}\" }.join(\"\\n  \")}\n    HEREDOC\n  end\n\n  @layout_hash = @envs['layout']\n\n  @logger.debug do\n    <<~HEREDOC\n      mode=\"\#{@mode}\"\n      page attributes:\n        \#{@page.sort\n               .reject { |k, _| REJECTED_ATTRIBUTES.include? k }\n               .map { |k, v| \"\#{k}=\#{v}\" }\n               .join(\"\\n  \")}\n    HEREDOC\n  end\n\n  # Compute the return value of this Jekyll tag\n  <<~HEREDOC\n    <p style='color: green; background-color: yellow; padding: 1em; border: solid thin grey;'>\n      \#{content} \#{@param1}\n      \#{@helper.attribute if @helper.attribution}\n    </p>\n  HEREDOC\nrescue StandardError => e\n  @logger.error { \"\#{self.class} died with a \#{e.full_message}\" }\n  exit 3\nend\n"