Class: JekyllSupport::HrefSummary
- Inherits:
-
JekyllTag
- Object
- JekyllTag
- JekyllSupport::HrefSummary
- Includes:
- JekyllHrefVersion
- Defined in:
- lib/href_summary_tag.rb
Constant Summary
Constants included from JekyllHrefVersion
Class Attribute Summary collapse
-
.hrefs ⇒ Object
Returns the value of attribute hrefs.
-
.hrefs_local ⇒ Object
Returns the value of attribute hrefs_local.
Instance Method Summary collapse
- #render_global_refs ⇒ Object
-
#render_impl ⇒ String
Method prescribed by the Jekyll plugin lifecycle.
- #render_local_refs ⇒ Object
Class Attribute Details
.hrefs ⇒ Object
Returns the value of attribute hrefs.
18 19 20 |
# File 'lib/href_summary_tag.rb', line 18 def hrefs @hrefs end |
.hrefs_local ⇒ Object
Returns the value of attribute hrefs_local.
18 19 20 |
# File 'lib/href_summary_tag.rb', line 18 def hrefs_local @hrefs_local end |
Instance Method Details
#render_global_refs ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/href_summary_tag.rb', line 49 def render_global_refs hrefs = HashArray.instance_variable_get(:@global_hrefs) entries = hrefs[@path]&.select { |h| h.path == @path } return '' if entries.nil? || entries.empty? summaries = entries.map { |href| "<li>#{href.summary_href}</li>" } " <h2 id=\"reference\">References</h2>\n <ol>\n \#{summaries.join \"\\n \"}\n </ol>\n END_RENDER\nrescue StandardError => e\n @logger.error { \"\#{self.class} died with a \#{e.full_message}\" }\n exit 1\nend\n" |
#render_impl ⇒ String
Method prescribed by the Jekyll plugin lifecycle.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/href_summary_tag.rb', line 26 def render_impl @helper.gem_file __FILE__ # Enables attribution @include_local = @helper.parameter_specified? 'include_local' @die_on_href_error = @tag_config['die_on_href_error'] == true if @tag_config @pry_on_href_error = @tag_config['pry_on_href_error'] == true if @tag_config @path = @page['path'] global_refs = render_global_refs local_refs = render_local_refs have_refs = !(global_refs + local_refs).empty? " \#{global_refs}\n \#{local_refs}\n \#{@helper.attribute if @helper.attribution && have_refs}\n END_RENDER\nrescue HrefError => e # jekyll_plugin_support handles StandardError\n @logger.error { e.logger_message }\n exit! 1 if @die_on_demo_block_error\n\n e.html_message\nend\n" |
#render_local_refs ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/href_summary_tag.rb', line 67 def render_local_refs return '' unless @include_local hrefs = HashArray.instance_variable_get(:@local_hrefs) entries = hrefs[@path]&.select { |h| h.path == @path } return '' if entries.nil? || entries.empty? summary = entries.map { |href| "<li>#{href.summary_href}</li>" } " <h2 id=\"local_reference\">Local References</h2>\n <ol>\n \#{summary.join(\"\\n \")}\n </ol>\n END_RENDER\nend\n" |