diff --git a/src/View/Antlers/Language/Parser/AntlersNodeParser.php b/src/View/Antlers/Language/Parser/AntlersNodeParser.php index 10291a6fc3..606c8a3c84 100644 --- a/src/View/Antlers/Language/Parser/AntlersNodeParser.php +++ b/src/View/Antlers/Language/Parser/AntlersNodeParser.php @@ -545,7 +545,7 @@ private function getParameters(AntlersNode $node) if ($hasFoundName == false && $current == DocumentParser::Punctuation_Equals) { if (! empty($currentChars)) { - if (! (ctype_alpha($currentChars[0]) || ctype_digit($currentChars[0]) || $currentChars[0] == DocumentParser::Punctuation_Colon || $currentChars[0] == DocumentParser::AtChar)) { + if (! (ctype_alpha($currentChars[0]) || ctype_digit($currentChars[0]) || $currentChars[0] == DocumentParser::Punctuation_Colon || $currentChars[0] == DocumentParser::AtChar || $currentChars[0] == DocumentParser::String_EscapeCharacter)) { $currentChars = []; continue; @@ -672,7 +672,7 @@ private function getParameters(AntlersNode $node) } } - if (Str::startsWith($name, DocumentParser::AtChar)) { + if (Str::startsWith($name, DocumentParser::String_EscapeCharacter)) { $parameterNode->containsEscapedContent = true; $name = mb_substr($name, 1); } diff --git a/src/View/Antlers/Language/Parser/DocumentParser.php b/src/View/Antlers/Language/Parser/DocumentParser.php index 4a991712a0..a387ca0d69 100644 --- a/src/View/Antlers/Language/Parser/DocumentParser.php +++ b/src/View/Antlers/Language/Parser/DocumentParser.php @@ -1057,7 +1057,7 @@ private function scanToEndOfAntlersRegion() } } - if ($this->cur == self::AtChar && ($this->prev != null && ctype_space($this->prev))) { + if ($this->cur == self::String_EscapeCharacter && ($this->prev != null && ctype_space($this->prev))) { if ($this->next != null && (ctype_alpha($this->next) || $this->next == self::Punctuation_Underscore || $this->next == self::AtChar)) { // It is possible that we might be starting some escaped content. // We will need more information to determine this, but let's diff --git a/tests/Antlers/Parser/NodeParametersTest.php b/tests/Antlers/Parser/NodeParametersTest.php index 35b924f232..c4d29e4c94 100644 --- a/tests/Antlers/Parser/NodeParametersTest.php +++ b/tests/Antlers/Parser/NodeParametersTest.php @@ -252,7 +252,7 @@ public function test_double_braces_inside_a_parameter_emits_final_literal_node_i $this->assertSame('FINAL_LITERAL', $nodes[2]->content); $template = <<<'EOT' -
{{ partial src="svg/" values="{{ article_icon_color:key }} {{ article_icon_size:key }}" }}FINAL_LITERAL
+
{{ partial src="svg/" values="{{ article_icon_color:key }} {{ article_icon_size:key }}" }}FINAL_LITERAL
EOT; $nodes = $this->parseNodes($template); @@ -263,7 +263,7 @@ public function test_double_braces_inside_a_parameter_emits_final_literal_node_i $this->assertInstanceOf(LiteralNode::class, $nodes[2]); $this->assertSame('
', $nodes[0]->content); - $this->assertSame('FINAL_LITERAL
', $nodes[2]->content); + $this->assertSame('FINAL_LITERAL ', $nodes[2]->content); } public function test_shorthand_variable_syntax() @@ -332,7 +332,7 @@ public function test_it_parses_shorthand_parameters_and_regular_parameters() public function test_curly_braces_inside_a_parameter_can_be_ignored_entirely() { $template = <<<'EOT' -{{ form @x-data="{ open: false }" @attr:x-bind="..." @x-init="() => { open = true }" x-show="open" }} +{{ form \x-data="{ open: false }" \attr:x-bind="..." \x-init="() => { open = true }" x-show="open" }} EOT; $nodes = $this->parseNodes($template); @@ -348,17 +348,17 @@ public function test_curly_braces_inside_a_parameter_can_be_ignored_entirely() $pXData = $antlersNode->parameters[0]; $this->assertSame('x-data', $pXData->name); - $this->assertSame('@x-data', $pXData->originalName); + $this->assertSame('\x-data', $pXData->originalName); $this->assertSame('{ open: false }', $pXData->value); $pXBind = $antlersNode->parameters[1]; $this->assertSame('attr:x-bind', $pXBind->name); - $this->assertSame('@attr:x-bind', $pXBind->originalName); + $this->assertSame('\attr:x-bind', $pXBind->originalName); $this->assertSame('...', $pXBind->value); $pXInit = $antlersNode->parameters[2]; $this->assertSame('x-init', $pXInit->name); - $this->assertSame('@x-init', $pXInit->originalName); + $this->assertSame('\x-init', $pXInit->originalName); $this->assertSame('() => { open = true }', $pXInit->value); $pXShow = $antlersNode->parameters[3];