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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix regression in Convertible module from v4.2.0 #8786

Merged
merged 2 commits into from
Aug 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 32 additions & 0 deletions features/rendering.feature
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,35 @@ Feature: Rendering
And I should see "series named {{ site.title }}" in "_site/index.html"
And I should see "{% link series/first-part.md %}" in "_site/index.html"
And I should see "{% link series/last-part.md %}" in "_site/index.html"

Scenario: Render content of another page
Given I have an "index.md" page that contains "__Hello World__"
And I have an "about.md" page that contains "{{ page.name }}"
And I have a "test.json" file with content:
"""
---
---

{
"hpages": [
{%- for page in site.html_pages %}
{
"url" : {{ page.url | jsonify }},
"name" : {{ page.name | jsonify }},
"path" : {{ page.path | jsonify }},
"title" : {{ page.title | jsonify }},
"layout" : {{ page.layout | jsonify }},
"content": {{ page.content | jsonify }},
"excerpt": {{ page.excerpt | jsonify }}
}{% unless forloop.last %},{% endunless -%}
{% endfor %}
]
}
"""
When I run jekyll build
Then I should get a zero exit status
And the _site directory should exist
But I should not see "content\": \"{{ page.name }}" in "_site/test.json"
And I should not see "content\": \"__Hello World__" in "_site/test.json"
But I should see "content\": \"<p>about.md</p>" in "_site/test.json"
And I should see "content\": \"<p><strong>Hello World</strong></p>" in "_site/test.json"
13 changes: 5 additions & 8 deletions lib/jekyll/convertible.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ def render_liquid(content, payload, info, path)
#
# Returns the Hash representation of this Convertible.
def to_liquid(attrs = nil)
further_data = attribute_hash(attrs || self.class::ATTRIBUTES_FOR_LIQUID)
further_data = \
(attrs || self.class::ATTRIBUTES_FOR_LIQUID).each_with_object({}) do |attribute, hsh|
hsh[attribute] = send(attribute)
end

Utils.deep_merge_hashes defaults, Utils.deep_merge_hashes(data, further_data)
end

Expand Down Expand Up @@ -246,13 +250,6 @@ def defaults
@defaults ||= site.frontmatter_defaults.all(relative_path, type)
end

def attribute_hash(attrs)
@attribute_hash ||= {}
@attribute_hash[attrs] ||= attrs.each_with_object({}) do |attribute, hsh|
hsh[attribute] = send(attribute)
end
end

def no_layout?
data["layout"] == "none"
end
Expand Down