Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No layouts for excerpt #1339

Merged
merged 16 commits into from Jul 24, 2013
Merged

No layouts for excerpt #1339

merged 16 commits into from Jul 24, 2013

Conversation

@parkr
Copy link
Member

@parkr parkr commented Jul 22, 2013

Aims to fix #1321.

  • Don't put excerpts in layouts
  • Convert layouts with converter
  • Render liquid
  • Write tests so it never happens again
  • Fix shitty tests so it really never happens again
@@ -249,12 +252,13 @@ def render(layouts, site_payload)
# construct payload
payload = {
"site" => { "related_posts" => related_posts(site_payload["site"]["posts"]) },
"page" => self.to_liquid
"page" => self.to_liquid(EXCERPT_ATTRIBUTES_FOR_LIQUID)
Copy link
Member Author

@parkr parkr Jul 22, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattr- The key to get it to convert was to make sure Post#excerpt was not called before the excerpt was converted. This seems to fix all the things!

Loading

@parkr
Copy link
Member Author

@parkr parkr commented Jul 22, 2013

@benbalter this will likely be my last PR for v1.1.1 so we can get it shipped today or (at the very latest) tomorrow.

Loading

@@ -0,0 +1,50 @@
Feature: Post excerpts
As a hacker who likes to blog
I want to be able to make a static sitej
Copy link
Contributor

@benbalter benbalter Jul 22, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/sitej/site/

Loading

Given I have an "index.html" page that contains "{% for post in site.posts %}{{ post.excerpt }}{% endfor %}"
And I have a _posts directory
And I have a _layouts directory
And I have a post layout that contains "{{ page.excerpt }}"
Copy link
Member

@mattr- mattr- Jul 22, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be {{ post.excerpt }} for consistency?

Loading

Copy link
Member Author

@parkr parkr Jul 23, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the variable used in the layout is page, not post

Loading

Copy link
Member

@mattr- mattr- Jul 23, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😕 Why is it page and not post? Seems weird to me.

Loading

Copy link
Member Author

@parkr parkr Jul 23, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's to be consistent so you can use the same layout for pages and for posts if you want.

Always the same variable for the #to_liquid hash

Loading

Copy link
Member

@mattr- mattr- Jul 24, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, got it. Merging shortly.

Loading

@mattr-
Copy link
Member

@mattr- mattr- commented Jul 22, 2013

Just the one fixup and I think this should be good.

Loading

@parkr
Copy link
Member Author

@parkr parkr commented Jul 23, 2013

@mattr- Please merge when ready :)

Loading

@parkr parkr mentioned this pull request Jul 23, 2013
mattr- added a commit that referenced this issue Jul 24, 2013
@mattr- mattr- merged commit d68d29c into master Jul 24, 2013
1 check passed
Loading
mattr- added a commit that referenced this issue Jul 24, 2013
@parkr parkr deleted the no-layouts-for-excerpt branch Jul 24, 2013
nitoyon
Copy link
Contributor

nitoyon commented on 26dc148 Sep 22, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because Array#concat is destructive, ATTRIBUTES_FOR_LIQUID and EXCERPT_ATTRIBUTES_FOR_LIQUID refers to the same array.

irb(main):001:0> a = [1]
=> [1]
irb(main):002:0> a.concat [2]
=> [1, 2]
irb(main):003:0> a
=> [1, 2]

You should write as following:

ATTRIBUTES_FOR_LIQUID = EXCERPT_ATTRIBUTES_FOR_LIQUID + %w[
  content
  excerpt
]

Loading

parkr
Copy link
Member

parkr commented on 26dc148 Sep 22, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bollocks, you're right. It doesn't look like it's a problem so far, but I'll fix that per this info. Thanks!

Loading

@jekyll jekyll locked and limited conversation to collaborators Feb 27, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

5 participants