Class: Jekyll::Excerpt
- Inherits:
-
Object
- Object
- Jekyll::Excerpt
- Includes:
- Convertible
- Defined in:
- lib/jekyll/excerpt.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#ext ⇒ Object
Returns the value of attribute ext.
-
#output ⇒ Object
Returns the value of attribute output.
-
#post ⇒ Object
Returns the value of attribute post.
Instance Method Summary collapse
-
#data ⇒ Object
Fetch YAML front-matter data from related post, without layout key.
-
#id ⇒ Object
The UID for this post (useful in feeds).
-
#include?(something) ⇒ Boolean
Check if excerpt includes a string.
-
#initialize(post) ⇒ Excerpt
constructor
Initialize this Post instance.
-
#inspect ⇒ Object
Returns the shorthand String identifier of this Post.
-
#path ⇒ Object
‘Path’ of the excerpt.
- #to_liquid ⇒ Object
- #to_s ⇒ Object
Methods included from Convertible
#converter, #do_layout, #output_ext, #read_yaml, #render_all_layouts, #render_liquid, #transform, #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.
15 16 17 18 |
# File 'lib/jekyll/excerpt.rb', line 15 def initialize(post) self.post = post self.content = extract_excerpt(post.content) end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
6 7 8 |
# File 'lib/jekyll/excerpt.rb', line 6 def content @content end |
#ext ⇒ Object
Returns the value of attribute ext.
6 7 8 |
# File 'lib/jekyll/excerpt.rb', line 6 def ext @ext end |
#output ⇒ Object
Returns the value of attribute output.
6 7 8 |
# File 'lib/jekyll/excerpt.rb', line 6 def output @output end |
#post ⇒ Object
Returns the value of attribute post.
5 6 7 |
# File 'lib/jekyll/excerpt.rb', line 5 def post @post end |
Instance Method Details
#data ⇒ Object
Fetch YAML front-matter data from related post, without layout key
Returns Hash of post data
33 34 35 36 37 |
# File 'lib/jekyll/excerpt.rb', line 33 def data @data ||= post.data.dup @data.delete("layout") @data end |
#id ⇒ Object
The UID for this post (useful in feeds). e.g. /2008/11/05/my-awesome-post
Returns the String UID.
57 58 59 |
# File 'lib/jekyll/excerpt.rb', line 57 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
49 50 51 |
# File 'lib/jekyll/excerpt.rb', line 49 def include?(something) (self.output && self.output.include?(something)) || self.content.include?(something) end |
#inspect ⇒ Object
Returns the shorthand String identifier of this Post.
66 67 68 |
# File 'lib/jekyll/excerpt.rb', line 66 def inspect "<Excerpt: #{self.id}>" end |
#path ⇒ Object
‘Path’ of the excerpt.
Returns the path for the post this excerpt belongs to with #excerpt appended
42 43 44 |
# File 'lib/jekyll/excerpt.rb', line 42 def path File.join(post.path, "#excerpt") end |
#to_liquid ⇒ Object
26 27 28 |
# File 'lib/jekyll/excerpt.rb', line 26 def to_liquid post.to_liquid(Post::EXCERPT_ATTRIBUTES_FOR_LIQUID) end |
#to_s ⇒ Object
61 62 63 |
# File 'lib/jekyll/excerpt.rb', line 61 def to_s self.output || self.content end |