Class: JekyllSupport::HRefTag

Inherits:
JekyllTag
  • Object
show all
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

JekyllHrefVersion::VERSION

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#followObject (readonly)

Returns the value of attribute follow.



21
22
23
# File 'lib/href_tag.rb', line 21

def follow
  @follow
end

#helperObject (readonly)

Returns the value of attribute helper.



21
22
23
# File 'lib/href_tag.rb', line 21

def helper
  @helper
end

#line_numberObject (readonly)

Returns the value of attribute line_number.



21
22
23
# File 'lib/href_tag.rb', line 21

def line_number
  @line_number
end

Returns the value of attribute link.



23
24
25
# File 'lib/href_tag.rb', line 23

def link
  @link
end

Returns the value of attribute link_save.



21
22
23
# File 'lib/href_tag.rb', line 21

def link_save
  @link_save
end

#matchObject (readonly)

Returns the value of attribute match.



21
22
23
# File 'lib/href_tag.rb', line 21

def match
  @match
end

#pageObject (readonly)

Returns the value of attribute page.



21
22
23
# File 'lib/href_tag.rb', line 21

def page
  @page
end

#pathObject (readonly)

Returns the value of attribute path.



21
22
23
# File 'lib/href_tag.rb', line 21

def path
  @path
end

#siteObject (readonly)

Returns the value of attribute site.



21
22
23
# File 'lib/href_tag.rb', line 21

def site
  @site
end

#summaryObject (readonly)

Returns the value of attribute summary.



21
22
23
# File 'lib/href_tag.rb', line 21

def summary
  @summary
end

#summary_excludeObject (readonly)

Returns the value of attribute summary_exclude.



21
22
23
# File 'lib/href_tag.rb', line 21

def summary_exclude
  @summary_exclude
end

#summary_hrefObject (readonly)

Returns the value of attribute summary_href.



21
22
23
# File 'lib/href_tag.rb', line 21

def summary_href
  @summary_href
end

#targetObject (readonly)

Returns the value of attribute target.



21
22
23
# File 'lib/href_tag.rb', line 21

def target
  @target
end

#textObject (readonly)

Returns the value of attribute text.



21
22
23
# File 'lib/href_tag.rb', line 21

def text
  @text
end

#urlObject (readonly)

Returns the value of attribute url.



21
22
23
# File 'lib/href_tag.rb', line 21

def url
  @url
end

Instance Method Details

#<=>(other) ⇒ Object



29
30
31
32
33
# File 'lib/href_tag.rb', line 29

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

#render_implString

Method prescribed by the Jekyll plugin lifecycle.

Parameters:

  • liquid_context (Liquid::Context)

Returns:

  • (String)


38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/href_tag.rb', line 38

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
  raise HrefError, '@link_type was not set' if @link_type == LinkType::UNKNOWN

  save_summary
  klass = " class='#{@klass}'" if @klass
  style = " style='#{@style}'" if @style
  "<a href='#{@link}'#{klass}#{style}#{@target}#{@follow}>#{@text}</a>"
rescue HRefError => e # jekyll_plugin_support handles StandardError
  @logger.error { e.logger_message }
  exit 1 if @die_on_demo_tag_error

  e.html_message
end

#to_sObject



63
64
65
# File 'lib/href_tag.rb', line 63

def to_s
  "On line #{line_number} of #{path}: #{follow} #{match} #{target} #{link} => '#{text}'"
end