Fix passing multiline params to include tag when using the variable syntax (#6858)

Merge pull request 6858
This commit is contained in:
ashmaroli 2018-03-22 03:54:04 +05:30 committed by jekyllbot
parent f7b5e313c1
commit 8f3363e2dc
2 changed files with 59 additions and 1 deletions

View File

@ -19,7 +19,7 @@ module Jekyll
VARIABLE_SYNTAX = %r!
(?<variable>[^{]*(\{\{\s*[\w\-\.]+\s*(\|.*)?\}\}[^\s{}]*)+)
(?<params>.*)
!x
!mx
FULL_VALID_SYNTAX = %r!\A\s*(?:#{VALID_SYNTAX}(?=\s|\z)\s*)*\z!
VALID_FILENAME_CHARS = %r!^[\w/\.-]+$!

View File

@ -948,6 +948,64 @@ CONTENT
end
end
context "with simple syntax but multiline markup" do
setup do
content = <<CONTENT
---
title: Include tag parameters
---
{% include sig.markdown myparam="test" %}
{% include params.html
param="value" %}
CONTENT
create_post(content, {
"permalink" => "pretty",
"source" => source_dir,
"destination" => dest_dir,
"read_posts" => true,
})
end
should "correctly output include variable" do
assert_match "<span id=\"include-param\">value</span>", @result.strip
end
should "ignore parameters if unused" do
assert_match "<hr />\n<p>Tom Preston-Werner\ngithub.com/mojombo</p>\n", @result
end
end
context "with variable syntax but multiline markup" do
setup do
content = <<CONTENT
---
title: Include tag parameters
---
{% include sig.markdown myparam="test" %}
{% assign path = "params" | append: ".html" %}
{% include {{ path }}
param="value" %}
CONTENT
create_post(content, {
"permalink" => "pretty",
"source" => source_dir,
"destination" => dest_dir,
"read_posts" => true,
})
end
should "correctly output include variable" do
assert_match "<span id=\"include-param\">value</span>", @result.strip
end
should "ignore parameters if unused" do
assert_match "<hr />\n<p>Tom Preston-Werner\ngithub.com/mojombo</p>\n", @result
end
end
context "with invalid parameter syntax" do
should "throw a ArgumentError" do
content = <<CONTENT