diff --git a/features/post_data.feature b/features/post_data.feature
index 79b92c26..c288115d 100644
--- a/features/post_data.feature
+++ b/features/post_data.feature
@@ -251,6 +251,19 @@ Feature: Post data
And I should see "Post categories: scifi and Movies" in "_site/scifi/movies/2009/03/27/star-wars.html"
And I should see "Post categories: SciFi and movies" in "_site/scifi/movies/2013/03/17/star-trek.html"
+Scenario: Use page.render_with_liquid variable
+ Given I have a _posts directory
+ And I have the following posts:
+ | title | render_with_liquid | date | content |
+ | Unrendered Post | false | 2017-07-06 | Hello {{ page.title }} |
+ | Rendered Post | true | 2017-07-06 | Hello {{ page.title }} |
+ When I run jekyll build
+ Then I should get a zero exit status
+ And the _site directory should exist
+ And I should not see "Hello Unrendered Post" in "_site/2017/07/06/unrendered-post.html"
+ But I should see "Hello {{ page.title }}" in "_site/2017/07/06/unrendered-post.html"
+ And I should see "Hello Rendered Post" in "_site/2017/07/06/rendered-post.html"
+
Scenario Outline: Use page.path variable
Given I have a
/_posts directory
And I have the following post in "":
diff --git a/lib/jekyll/convertible.rb b/lib/jekyll/convertible.rb
index 5e703505..85532ba9 100644
--- a/lib/jekyll/convertible.rb
+++ b/lib/jekyll/convertible.rb
@@ -160,6 +160,7 @@ module Jekyll
#
# Returns true if the file has Liquid Tags or Variables, false otherwise.
def render_with_liquid?
+ return false if data["render_with_liquid"] == false
Jekyll::Utils.has_liquid_construct?(content)
end
diff --git a/lib/jekyll/document.rb b/lib/jekyll/document.rb
index dbc1a6d8..8b6e54e3 100644
--- a/lib/jekyll/document.rb
+++ b/lib/jekyll/document.rb
@@ -159,6 +159,7 @@ module Jekyll
# or if the document doesn't contain any Liquid Tags or Variables,
# true otherwise.
def render_with_liquid?
+ return false if data["render_with_liquid"] == false
!(coffeescript_file? || yaml_file? || !Utils.has_liquid_construct?(content))
end
diff --git a/test/fixtures/no_liquid.erb b/test/fixtures/no_liquid.erb
new file mode 100644
index 00000000..bfb7fc46
--- /dev/null
+++ b/test/fixtures/no_liquid.erb
@@ -0,0 +1,4 @@
+---
+render_with_liquid: false
+---
+{% raw %}{% endraw %}
diff --git a/test/test_convertible.rb b/test/test_convertible.rb
index a3bea6ba..8c204ebf 100644
--- a/test/test_convertible.rb
+++ b/test/test_convertible.rb
@@ -73,5 +73,12 @@ class TestConvertible < JekyllUnitTest
end
refute_match(%r!Invalid permalink!, out)
end
+
+ should "not parse Liquid if disabled in front matter" do
+ name = "no_liquid.erb"
+ @convertible.read_yaml(@base, name)
+ ret = @convertible.content.strip
+ assert_equal("{% raw %}{% endraw %}", ret)
+ end
end
end