Fix passing multiline params to include tag when using the variable syntax (#6858)
Merge pull request 6858
This commit is contained in:
parent
f7b5e313c1
commit
8f3363e2dc
|
@ -19,7 +19,7 @@ module Jekyll
|
||||||
VARIABLE_SYNTAX = %r!
|
VARIABLE_SYNTAX = %r!
|
||||||
(?<variable>[^{]*(\{\{\s*[\w\-\.]+\s*(\|.*)?\}\}[^\s{}]*)+)
|
(?<variable>[^{]*(\{\{\s*[\w\-\.]+\s*(\|.*)?\}\}[^\s{}]*)+)
|
||||||
(?<params>.*)
|
(?<params>.*)
|
||||||
!x
|
!mx
|
||||||
|
|
||||||
FULL_VALID_SYNTAX = %r!\A\s*(?:#{VALID_SYNTAX}(?=\s|\z)\s*)*\z!
|
FULL_VALID_SYNTAX = %r!\A\s*(?:#{VALID_SYNTAX}(?=\s|\z)\s*)*\z!
|
||||||
VALID_FILENAME_CHARS = %r!^[\w/\.-]+$!
|
VALID_FILENAME_CHARS = %r!^[\w/\.-]+$!
|
||||||
|
|
|
@ -948,6 +948,64 @@ CONTENT
|
||||||
end
|
end
|
||||||
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
|
context "with invalid parameter syntax" do
|
||||||
should "throw a ArgumentError" do
|
should "throw a ArgumentError" do
|
||||||
content = <<CONTENT
|
content = <<CONTENT
|
||||||
|
|
Loading…
Reference in New Issue