diff --git a/src/Liquid/AbstractBlock.php b/src/Liquid/AbstractBlock.php index 0d29f01..4ca05b2 100644 --- a/src/Liquid/AbstractBlock.php +++ b/src/Liquid/AbstractBlock.php @@ -254,7 +254,7 @@ private function blockName() */ private function createVariable($token) { - $variableRegexp = new Regexp('/^' . Liquid::get('VARIABLE_START') . Liquid::get('WHITESPACE_CONTROL') . '?(.*?)' . Liquid::get('WHITESPACE_CONTROL') . '?' . Liquid::get('VARIABLE_END') . '$/'); + $variableRegexp = new Regexp('/^' . Liquid::get('VARIABLE_START') . Liquid::get('WHITESPACE_CONTROL') . '?(.*?)' . Liquid::get('WHITESPACE_CONTROL') . '?' . Liquid::get('VARIABLE_END') . '$/s'); if ($variableRegexp->match($token)) { return new Variable($variableRegexp->matches[1]); } diff --git a/src/Liquid/Variable.php b/src/Liquid/Variable.php index 868738a..6afeb05 100644 --- a/src/Liquid/Variable.php +++ b/src/Liquid/Variable.php @@ -41,7 +41,7 @@ public function __construct($markup) $this->markup = $markup; $filterSep = new Regexp('/' . Liquid::get('FILTER_SEPARATOR') . '\s*(.*)/m'); - $syntaxParser = new Regexp('/(' . Liquid::get('QUOTED_FRAGMENT') . ')(.*)/m'); + $syntaxParser = new Regexp('/(' . Liquid::get('QUOTED_FRAGMENT') . ')(.*)/ms'); $filterParser = new Regexp('/(?:\s+|' . Liquid::get('QUOTED_FRAGMENT') . '|' . Liquid::get('ARGUMENT_SEPARATOR') . ')+/'); $filterArgsRegex = new Regexp('/(?:' . Liquid::get('FILTER_ARGUMENT_SEPARATOR') . '|' . Liquid::get('ARGUMENT_SEPARATOR') . ')\s*((?:\w+\s*\:\s*)?' . Liquid::get('QUOTED_FRAGMENT') . ')/'); diff --git a/tests/Liquid/OutputTest.php b/tests/Liquid/OutputTest.php index 4eac2e9..a18b048 100644 --- a/tests/Liquid/OutputTest.php +++ b/tests/Liquid/OutputTest.php @@ -188,9 +188,6 @@ public function testLinkTo() */ public function testVariableWithANewLine() { - $this->expectException(\Liquid\Exception\ParseException::class); - $this->expectExceptionMessage('was not properly terminated'); - $text = "{{ aaa\n }}"; $this->assertTemplateResult('', $text, $this->assigns); } diff --git a/tests/Liquid/VariableResolutionTest.php b/tests/Liquid/VariableResolutionTest.php index 3f8a26c..28a3f07 100644 --- a/tests/Liquid/VariableResolutionTest.php +++ b/tests/Liquid/VariableResolutionTest.php @@ -37,6 +37,14 @@ public function testIgnoreUnknown() $this->assertEquals('', $template->render()); } + public function testLineBreak() + { + $template = new Template(); + + $template->parse("{{ test |\n strip_html }}"); + $this->assertEquals('worked', $template->render(array('test' => 'worked'))); + } + public function testArrayScoping() { $template = new Template();