Class: Jekyll::Excerpt

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Convertible

#[], #asset_file?, #coffeescript_file?, #converters, #do_layout, #invalid_layout?, #merged_file_read_opts, #output_ext, #place_in_layout?, #published?, #read_yaml, #render_all_layouts, #render_liquid, #render_with_liquid?, #sass_file?, #transform, #type, #write

Constructor Details

#initialize(post) ⇒ Excerpt

Initialize this Post instance.

site - The Site. base - The String path to the dir containing the post file. name - The String filename of the post file.

Returns the new Post.


22
23
24
25
# File 'lib/jekyll/excerpt.rb', line 22

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

Instance Attribute Details

#contentObject

Returns the value of attribute content


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

def content
  @content
end

#extObject

Returns the value of attribute ext


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

def ext
  @ext
end

#outputObject

Returns the value of attribute output


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

def output
  @output
end

#postObject

Returns the value of attribute post


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

def post
  @post
end

Instance Method Details

#dataObject

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

Returns Hash of post data


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

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

#idObject

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

Returns the String UID.


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

def id
  File.join(post.dir, post.slug, "#excerpt")
end

#include?(something) ⇒ Boolean

Check if excerpt includes a string

Returns true if the string passed in

Returns:

  • (Boolean)

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

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

#inspectObject

Returns the shorthand String identifier of this Post.


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

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

#pathObject

'Path' of the excerpt.

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


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

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

#to_liquidObject


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

def to_liquid
  post.to_liquid(post.class::EXCERPT_ATTRIBUTES_FOR_LIQUID)
end

#to_sObject


62
63
64
# File 'lib/jekyll/excerpt.rb', line 62

def to_s
  output || content
end