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

Backport #6945 #6970

Merged
merged 1 commit into from May 1, 2018
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
19 changes: 19 additions & 0 deletions features/post_excerpts.feature
Expand Up @@ -34,6 +34,25 @@ Feature: Post excerpts
And I should see exactly "<p>content for entry1.</p>" in "_site/2007/12/31/entry1.html"
And I should see exactly "<p>content for entry1.</p>" in "_site/index.html"

Scenario: An excerpt with Liquid constructs from a post with a layout
Given I have an "index.html" page that contains "{% for post in site.posts %}{{ post.excerpt }}{% endfor %}"
And I have a configuration file with "baseurl" set to "/blog"
And I have a _posts directory
And I have a _layouts directory
And I have a post layout that contains "{{ page.excerpt }}"
And I have the following posts:
| title | date | layout | content |
| entry1 | 2007-12-31 | post | {{ 'assets/style.css' \| relative_url }} |
When I run jekyll build
Then I should get a zero exit status
And the _site directory should exist
And the _site/2007 directory should exist
And the _site/2007/12 directory should exist
And the _site/2007/12/31 directory should exist
And the "_site/2007/12/31/entry1.html" file should exist
And I should see exactly "<p>/blog/assets/style.css</p>" in "_site/2007/12/31/entry1.html"
And I should see exactly "<p>/blog/assets/style.css</p>" in "_site/index.html"

Scenario: An excerpt from a post with a layout which has context
Given I have an "index.html" page that contains "{% for post in site.posts %}{{ post.excerpt }}{% endfor %}"
And I have a _posts directory
Expand Down
9 changes: 8 additions & 1 deletion lib/jekyll/excerpt.rb
Expand Up @@ -9,9 +9,12 @@ class Excerpt
attr_writer :output

def_delegators :@doc, :site, :name, :ext, :extname,
:render_with_liquid?, :collection, :related_posts,
:collection, :related_posts,
:coffeescript_file?, :yaml_file?,
:url, :next_doc, :previous_doc

private :coffeescript_file?, :yaml_file?

# Initialize this Excerpt instance.
#
# doc - The Document.
Expand Down Expand Up @@ -84,6 +87,10 @@ def place_in_layout?
false
end

def render_with_liquid?
!(coffeescript_file? || yaml_file? || !Utils.has_liquid_construct?(content))
end

protected

# Internal: Extract excerpt from the content
Expand Down