Add support for liquid in post excerpts #1302

Merged
merged 2 commits into from Jul 14, 2013

Projects

None yet

3 participants

@parkr
Member
parkr commented Jul 13, 2013
  • Break out Excerpt into its own class, including Convertible
  • Hook excerpt rendering into post rendering
  • Fix post tests for excerpts so they render instead of just transform
  • Write tests specifically for Excerpt??

@mattr-

@parkr
Member
parkr commented Jul 13, 2013

@mattr- Please review. I'd love to push this out tomorrow!

@mattr- mattr- commented on the diff Jul 14, 2013
lib/jekyll/excerpt.rb
+ (output && output.include?(something)) || content.include?(something)
+ end
+
+ # The UID for this post (useful in feeds).
+ # e.g. /2008/11/05/my-awesome-post
+ #
+ # Returns the String UID.
+ def id
+ File.join(post.dir, post.slug, "#excerpt")
+ end
+
+ # Convert this post into a Hash for use in Liquid templates.
+ #
+ # Returns the representative Hash.
+ def to_liquid
+ further_data = Hash[ATTRIBUTES_FOR_LIQUID.map { |attribute|
@mattr-
mattr- Jul 14, 2013 Member

I'm not completely up to speed on Ruby's constant lookup. How does this ATTRIBUTES_FOR_LIQUID constant get resolved when it's actually on the Post class?

@parkr
parkr Jul 14, 2013 Member

Hm... no I don't think it does. Totally missed that!

@parkr
parkr Jul 14, 2013 Member

Also don't throw yourself under the bus by saying you're not up to speed - I know that's not true ;) ❤️

@parkr
parkr Jul 14, 2013 Member

Fixed it in d815c12 :)

@mattr-
Member
mattr- commented Jul 14, 2013

I love the extraction of the extract class here. That is fantastic.

We can add tests for Excerpt later, if needed, since it's just an implementation detail of a post.

I'm 👍 on this.

@mattr- mattr- merged commit 17c2296 into master Jul 14, 2013

1 check passed

default The Travis CI build passed
Details
@mattr- mattr- added a commit that referenced this pull request Jul 14, 2013
@mattr- mattr- Update history to reflect merge of #1302 21b52bb
@parkr parkr deleted the excerpt branch Jul 14, 2013
@rwboyer rwboyer commented on the diff Jul 15, 2013
lib/jekyll/post.rb
@@ -260,6 +252,8 @@ def render(layouts, site_payload)
"page" => self.to_liquid
}.deep_merge(site_payload)
+ self.extracted_excerpt.do_layout(payload, layouts)
@rwboyer
rwboyer Jul 15, 2013

Something feels strange right here...

haven't really dug in yet but guessing this is what is causing some serious strangeness with a lot of Jekyll sites since 1.1.0.

See issue #1307

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment