From 5701087e7b2b61dbea84b3782ca55195e348c5d4 Mon Sep 17 00:00:00 2001 From: Ken Salomon Date: Fri, 20 Jul 2018 19:22:44 -0400 Subject: [PATCH] Do not process Liquid in post excerpt when disabled in front matter (#7146) Merge pull request 7146 --- features/post_excerpts.feature | 18 ++++++++++++++++++ lib/jekyll/excerpt.rb | 1 + 2 files changed, 19 insertions(+) diff --git a/features/post_excerpts.feature b/features/post_excerpts.feature index 6267fdc6..38de7352 100644 --- a/features/post_excerpts.feature +++ b/features/post_excerpts.feature @@ -70,3 +70,21 @@ Feature: Post excerpts And the "_site/2007/12/31/entry1.html" file should exist And I should see "

content for entry1.

" in "_site/index.html" And I should see "

content for entry1.

\n" in "_site/2007/12/31/entry1.html" + + Scenario: Excerpts from posts having 'render_with_liquid' in their front matter + 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 }}" + And I have the following posts: + | title | layout | render_with_liquid | date | content | + | Unrendered Post | post | false | 2017-07-06 | Liquid is not rendered at {{ page.url }} | + | Rendered Post | post | true | 2017-07-06 | Liquid is rendered at {{ page.url }} | + When I run jekyll build + Then I should get a zero exit status + And the _site/2017/07/06 directory should exist + And the "_site/2017/07/06/unrendered-post.html" file should exist + And the "_site/2017/07/06/rendered-post.html" file should exist + And I should see "Liquid is not rendered at {{ page.url }}" in "_site/2017/07/06/unrendered-post.html" + But I should see "

Liquid is rendered at /2017/07/06/rendered-post.html

" in "_site/2017/07/06/rendered-post.html" + And I should see "

Liquid is not rendered at {{ page.url }}

\n

Liquid is rendered at /2017/07/06/rendered-post.html

" in "_site/index.html" diff --git a/lib/jekyll/excerpt.rb b/lib/jekyll/excerpt.rb index 6f4ac3d8..8eea0e2e 100644 --- a/lib/jekyll/excerpt.rb +++ b/lib/jekyll/excerpt.rb @@ -89,6 +89,7 @@ module Jekyll end def render_with_liquid? + return false if data["render_with_liquid"] == false !(coffeescript_file? || yaml_file? || !Utils.has_liquid_construct?(content)) end