Class: Jekyll::Excerpt

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(doc) ⇒ Excerpt

Initialize this Excerpt instance.

doc - The Document.

Returns the new Excerpt.



19
20
21
22
# File 'lib/jekyll/excerpt.rb', line 19

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



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

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



27
28
29
30
31
32
# File 'lib/jekyll/excerpt.rb', line 27

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.



55
56
57
# File 'lib/jekyll/excerpt.rb', line 55

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

#include?(something) ⇒ Boolean

Check if excerpt includes a string

Returns true if the string passed in

Returns:

  • (Boolean)


47
48
49
# File 'lib/jekyll/excerpt.rb', line 47

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

#inspectObject

Returns the shorthand String identifier of this doc.



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

def inspect
  "<Excerpt: #{self.id}>"
end

#pathObject

‘Path’ of the excerpt.

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



40
41
42
# File 'lib/jekyll/excerpt.rb', line 40

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

#place_in_layout?Boolean

Returns:

  • (Boolean)


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

def place_in_layout?
  false
end

#to_liquidObject



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

def to_liquid
  doc.data['excerpt'] = nil
  @to_liquid ||= doc.to_liquid
  doc.data['excerpt'] = self
  @to_liquid
end

#to_sObject



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

def to_s
  output || content
end

#trigger_hooksObject



34
35
# File 'lib/jekyll/excerpt.rb', line 34

def trigger_hooks(*)
end