From 8f3363e2dc090c460a37b77fad0c15c38683cca4 Mon Sep 17 00:00:00 2001 From: ashmaroli Date: Thu, 22 Mar 2018 03:54:04 +0530 Subject: [PATCH] Fix passing multiline params to include tag when using the variable syntax (#6858) Merge pull request 6858 --- lib/jekyll/tags/include.rb | 2 +- test/test_tags.rb | 58 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/lib/jekyll/tags/include.rb b/lib/jekyll/tags/include.rb index 1c4d6566..5836c4ac 100644 --- a/lib/jekyll/tags/include.rb +++ b/lib/jekyll/tags/include.rb @@ -19,7 +19,7 @@ module Jekyll VARIABLE_SYNTAX = %r! (?[^{]*(\{\{\s*[\w\-\.]+\s*(\|.*)?\}\}[^\s{}]*)+) (?.*) - !x + !mx FULL_VALID_SYNTAX = %r!\A\s*(?:#{VALID_SYNTAX}(?=\s|\z)\s*)*\z! VALID_FILENAME_CHARS = %r!^[\w/\.-]+$! diff --git a/test/test_tags.rb b/test/test_tags.rb index 5712a9f0..ae75c024 100644 --- a/test/test_tags.rb +++ b/test/test_tags.rb @@ -948,6 +948,64 @@ CONTENT end end + context "with simple syntax but multiline markup" do + setup do + content = < "pretty", + "source" => source_dir, + "destination" => dest_dir, + "read_posts" => true, + }) + end + + should "correctly output include variable" do + assert_match "value", @result.strip + end + + should "ignore parameters if unused" do + assert_match "
\n

Tom Preston-Werner\ngithub.com/mojombo

\n", @result + end + end + + context "with variable syntax but multiline markup" do + setup do + content = < "pretty", + "source" => source_dir, + "destination" => dest_dir, + "read_posts" => true, + }) + end + + should "correctly output include variable" do + assert_match "value", @result.strip + end + + should "ignore parameters if unused" do + assert_match "
\n

Tom Preston-Werner\ngithub.com/mojombo

\n", @result + end + end + context "with invalid parameter syntax" do should "throw a ArgumentError" do content = <