Class: Jekyll::Excerpt
- Inherits:
-
Object
- Object
- Jekyll::Excerpt
- Extended by:
- Forwardable
- 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
#[], #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
#content ⇒ Object
Returns the value of attribute content.
9 10 11 |
# File 'lib/jekyll/excerpt.rb', line 9 def content @content end |
#ext ⇒ Object
Returns the value of attribute ext.
9 10 11 |
# File 'lib/jekyll/excerpt.rb', line 9 def ext @ext end |
#output ⇒ Object
Returns the value of attribute output.
9 10 11 |
# File 'lib/jekyll/excerpt.rb', line 9 def output @output end |
#post ⇒ Object
Returns the value of attribute post.
8 9 10 |
# File 'lib/jekyll/excerpt.rb', line 8 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
34 35 36 37 38 |
# File 'lib/jekyll/excerpt.rb', line 34 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.
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
50 51 52 |
# File 'lib/jekyll/excerpt.rb', line 50 def include?(something) (output && output.include?(something)) || content.include?(something) end |
#inspect ⇒ Object
Returns the shorthand String identifier of this Post.
67 68 69 |
# File 'lib/jekyll/excerpt.rb', line 67 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
43 44 45 |
# File 'lib/jekyll/excerpt.rb', line 43 def path File.join(post.path, "#excerpt") end |
#to_liquid ⇒ Object
27 28 29 |
# File 'lib/jekyll/excerpt.rb', line 27 def to_liquid post.to_liquid(post.class::EXCERPT_ATTRIBUTES_FOR_LIQUID) end |
#to_s ⇒ Object
62 63 64 |
# File 'lib/jekyll/excerpt.rb', line 62 def to_s output || content end |