Class: Jekyll::Excerpt

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/jekyll/excerpt.rb

Direct Known Subclasses

PageExcerpt

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(doc) ⇒ Excerpt

Initialize this Excerpt instance.

doc - The Document.

Returns the new Excerpt.


24
25
26
27
# File 'lib/jekyll/excerpt.rb', line 24

def initialize(doc)
  self.doc = doc
  self.content = extract_excerpt(doc.content)
end

Instance Attribute Details

#contentObject

Returns the value of attribute content


8
9
10
# File 'lib/jekyll/excerpt.rb', line 8

def content
  @content
end

#docObject

Returns the value of attribute doc


7
8
9
# File 'lib/jekyll/excerpt.rb', line 7

def doc
  @doc
end

#extObject

Returns the value of attribute ext


8
9
10
# File 'lib/jekyll/excerpt.rb', line 8

def ext
  @ext
end

#outputObject


83
84
85
# File 'lib/jekyll/excerpt.rb', line 83

def output
  @output ||= Renderer.new(doc.site, self, site.site_payload).run
end

Instance Method Details

#dataObject

Fetch YAML front-matter data from related doc, without layout key

Returns Hash of doc data


32
33
34
35
36
37
# File 'lib/jekyll/excerpt.rb', line 32

def data
  @data ||= doc.data.dup
  @data.delete("layout")
  @data.delete("excerpt")
  @data
end

#idObject

The UID for this doc (useful in feeds). e.g. /2008/11/05/my-awesome-doc

Returns the String UID.


66
67
68
# File 'lib/jekyll/excerpt.rb', line 66

def id
  "#{doc.id}#excerpt"
end

#include?(something) ⇒ Boolean

Check if excerpt includes a string

Returns true if the string passed in

Returns:

  • (Boolean)

58
59
60
# File 'lib/jekyll/excerpt.rb', line 58

def include?(something)
  output&.include?(something) || content.include?(something)
end

#inspectObject

Returns the shorthand String identifier of this doc.


79
80
81
# File 'lib/jekyll/excerpt.rb', line 79

def inspect
  "<#{self.class} id=#{id}>"
end

#pathObject

'Path' of the excerpt.

Returns the path for the doc this excerpt belongs to with #excerpt appended


44
45
46
# File 'lib/jekyll/excerpt.rb', line 44

def path
  File.join(doc.path, "#excerpt")
end

#place_in_layout?Boolean

Returns:

  • (Boolean)

87
88
89
# File 'lib/jekyll/excerpt.rb', line 87

def place_in_layout?
  false
end

#relative_pathObject

'Relative Path' of the excerpt.

Returns the relative_path for the doc this excerpt belongs to with #excerpt appended


51
52
53
# File 'lib/jekyll/excerpt.rb', line 51

def relative_path
  @relative_path ||= File.join(doc.relative_path, "#excerpt")
end

#render_with_liquid?Boolean

Returns:

  • (Boolean)

91
92
93
94
95
# File 'lib/jekyll/excerpt.rb', line 91

def render_with_liquid?
  return false if data["render_with_liquid"] == false

  !(coffeescript_file? || yaml_file? || !Utils.has_liquid_construct?(content))
end

#to_liquidObject


74
75
76
# File 'lib/jekyll/excerpt.rb', line 74

def to_liquid
  Jekyll::Drops::ExcerptDrop.new(self)
end

#to_sObject


70
71
72
# File 'lib/jekyll/excerpt.rb', line 70

def to_s
  output || content
end

#trigger_hooksObject


39
# File 'lib/jekyll/excerpt.rb', line 39

def trigger_hooks(*); end