Class: JekyllSupport::HRefTag
- Inherits:
-
JekyllTag
- Object
- JekyllTag
- JekyllSupport::HRefTag
- Includes:
- Comparable, HashArray, JekyllHrefVersion
- Defined in:
- lib/href_tag.rb,
lib/href_match.rb,
lib/href_private.rb,
lib/href_summary.rb,
lib/href_page_title.rb
Overview
Implements href Jekyll tag
Constant Summary
Constants included from JekyllHrefVersion
Instance Attribute Summary collapse
-
#follow ⇒ Object
readonly
Returns the value of attribute follow.
-
#helper ⇒ Object
readonly
Returns the value of attribute helper.
-
#line_number ⇒ Object
readonly
Returns the value of attribute line_number.
-
#link ⇒ Object
Returns the value of attribute link.
-
#link_save ⇒ Object
readonly
Returns the value of attribute link_save.
-
#match ⇒ Object
readonly
Returns the value of attribute match.
-
#page ⇒ Object
readonly
Returns the value of attribute page.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#site ⇒ Object
readonly
Returns the value of attribute site.
-
#summary ⇒ Object
readonly
Returns the value of attribute summary.
-
#summary_exclude ⇒ Object
readonly
Returns the value of attribute summary_exclude.
-
#summary_href ⇒ Object
readonly
Returns the value of attribute summary_href.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object
- #inspect ⇒ Object
-
#render_impl ⇒ String
Method prescribed by the Jekyll plugin lifecycle.
- #to_s ⇒ Object
Methods included from HashArray
#add_global_link_for_page, add_global_link_for_page, add_link_for_page, #add_local_link_for_page, add_local_link_for_page, #reset, reset
Instance Attribute Details
#follow ⇒ Object (readonly)
Returns the value of attribute follow.
34 35 36 |
# File 'lib/href_tag.rb', line 34 def follow @follow end |
#helper ⇒ Object (readonly)
Returns the value of attribute helper.
34 35 36 |
# File 'lib/href_tag.rb', line 34 def helper @helper end |
#line_number ⇒ Object (readonly)
Returns the value of attribute line_number.
34 35 36 |
# File 'lib/href_tag.rb', line 34 def line_number @line_number end |
#link ⇒ Object
Returns the value of attribute link.
36 37 38 |
# File 'lib/href_tag.rb', line 36 def link @link end |
#link_save ⇒ Object (readonly)
Returns the value of attribute link_save.
34 35 36 |
# File 'lib/href_tag.rb', line 34 def link_save @link_save end |
#match ⇒ Object (readonly)
Returns the value of attribute match.
34 35 36 |
# File 'lib/href_tag.rb', line 34 def match @match end |
#page ⇒ Object (readonly)
Returns the value of attribute page.
34 35 36 |
# File 'lib/href_tag.rb', line 34 def page @page end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
34 35 36 |
# File 'lib/href_tag.rb', line 34 def path @path end |
#site ⇒ Object (readonly)
Returns the value of attribute site.
34 35 36 |
# File 'lib/href_tag.rb', line 34 def site @site end |
#summary ⇒ Object (readonly)
Returns the value of attribute summary.
34 35 36 |
# File 'lib/href_tag.rb', line 34 def summary @summary end |
#summary_exclude ⇒ Object (readonly)
Returns the value of attribute summary_exclude.
34 35 36 |
# File 'lib/href_tag.rb', line 34 def summary_exclude @summary_exclude end |
#summary_href ⇒ Object (readonly)
Returns the value of attribute summary_href.
34 35 36 |
# File 'lib/href_tag.rb', line 34 def summary_href @summary_href end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
34 35 36 |
# File 'lib/href_tag.rb', line 34 def target @target end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
34 35 36 |
# File 'lib/href_tag.rb', line 34 def text @text end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
34 35 36 |
# File 'lib/href_tag.rb', line 34 def url @url end |
Instance Method Details
#<=>(other) ⇒ Object
64 65 66 67 68 |
# File 'lib/href_tag.rb', line 64 def <=>(other) return nil unless other.is_a?(self.class) [follow, match, path, target, text] <=> [other.follow, other.match, other.path, other.target, other.text] end |
#==(other) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/href_tag.rb', line 42 def ==(other) case other when self.class follow == other.follow && match == other.match && path == other.path && target == other.target && text == other.text when MiniHref follow == other.follow && text == other.html && link == other.link && line_number == other.line_number && link_save == other.link_save && path == other.path && summary_exclude == other.summary_exclude && summary_href == other.summary_href else false end end |
#inspect ⇒ Object
129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/href_tag.rb', line 129 def inspect # "On line #{line_number} of #{path}:" msg = '<HRef' msg += follow unless follow.empty? msg += " match='#{match}'" if match msg += " path='#{path}'" # if path msg += target unless target.empty? msg += " link='#{link}'" # unless link.empty? msg += " text='#{text[0..20]}#{text.length > 20 ? "'..." : "'"}" unless text.empty? msg += '>' msg end |
#render_impl ⇒ String
Method prescribed by the Jekyll plugin lifecycle.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/href_tag.rb', line 73 def render_impl globals_initial linkk, error_msg = compute_linkk return error_msg unless linkk linkk.delete_prefix './' # normalize relative links @url = linkk if @url @link_save = linkk @helper_save = @helper.clone globals_update(@helper.argv, linkk) # Sets @link and @text, might clear @follow and @target handle_match(linkk) if @match # Sets @text if not set by now, also @link_type, etc. @link.gsub! ' ', '%20' raise HrefError, '@link_type was not set' if @link_type == LinkType::UNKNOWN save_summary klass = " class='#{@klass}'" if @klass style = " style='#{@style}'" if @style if @link_type == LinkType::LOCAL && @mode == 'production' && @label_source != LabelSource::FROM_IMPLICIT_LABEL && @link != '#' path, _fragment = @link.split('#') page = ::Jekyll::Draft.page_match path if ::Jekyll::Draft.draft? page klass = "draft_link #{@klass}".strip raise HrefError, "<span class='#{klass}'#{style}><span class='draft_title'>#{page.title}</span> <span class='draft_label'>#{@text}</span></span>" end end "<a href='#{@link}'#{klass}#{style}#{@target}#{@follow}>#{@text}</a>" rescue HrefError => e # jekyll_plugin_support handles StandardError @logger.error { JekyllPluginHelper. e. } exit 1 if @die_on_demo_tag_error e. end |
#to_s ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/href_tag.rb', line 116 def to_s # "On line #{line_number} of #{path}:" msg = '<HRef' msg += follow unless follow.empty? msg += " match='#{match}'" if match msg += " path='#{path}'" # if path msg += target unless target.empty? msg += " link='#{link}'" # unless link.empty? msg += " text='#{text}'" unless text.empty? msg += '>' msg end |