8000 Add top-level `layout` liquid variable to Documents by ayastreb · Pull Request #6073 · jekyll/jekyll · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add top-level layout liquid variable to Documents #6073

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

Merged
merged 1 commit into from
Jun 14, 2017

Conversation

ayastreb
Copy link
Contributor
@ayastreb ayastreb commented May 10, 2017

Fixes #6071

we add "layout" key to payload when we place doc into layout (see def render_layout), so when first doc is rendered - layout data is not present in payload and only added there after, so it is available for next documents.

In this PR I add layout data to payload before rendering the document.

@ayastreb ayastreb changed the title Fix layout front-matter variables rendering. #6071 Fix layout front-matter variables rendering May 10, 2017
@ghost ghost mentioned this pull request May 12, 2017
Copy link
Member
@parkr parkr left a comment

Choose a reason for hiding this comment

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

I'm not sure we can do that quite this easily...

@@ -234,6 +235,14 @@ def assign_highlighter_options!
end

private
def assign_layout_data!
layout = layouts[document.data["layout"]]
Copy link
Member

Choose a reason for hiding this comment

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

What do you do if that layout has layouts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure... basically the problem is that we don't have layout data in payload when we render document here. I've tried to move the place_in_layouts call before rendering the document (because we add layout data to payload in that method), but that breaks a lot of tests.

Not sure how to fix this without too much changes :)

@@ -54,6 +54,7 @@ def run
assign_pages!
assign_related_posts!
assign_highlighter_options!
assign_layout_data!
Copy link
Member

Choose a reason for hiding this comment

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

What if a plugin modifies the layout data?

@@ -234,6 +235,14 @@ def assign_highlighter_options!
end

private
def assign_layout_data!
layout = layouts[document.data["layout"]]
Copy link
Member

Choose a reason for hiding this comment

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

What if the document doesn't have a layout parameter? layouts[nil]?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ayastreb
Copy link
Contributor Author

hi @parkr !
how should we proceed with this PR? Do you see a different approach to fixing the bug or is this fine?

@parkr parkr changed the title Fix layout front-matter variables rendering Add top-level layout liquid variable to Documents Jun 14, 2017
@parkr
Copy link
Member
parkr commented Jun 14, 2017

@jekyllbot: merge +minor

@jekyllbot jekyllbot merged commit 2cfcb23 into jekyll:master Jun 14, 2017
jekyllbot added a commit that referenced this pull request Jun 14, 2017
@DirtyF DirtyF added this to the 3.5 milestone Jun 18, 2017
@jekyll jekyll locked and limited conversation to collaborators Jul 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

layout variable not available to index.html
4 participants
0