Skip to content

Commit

Permalink
Ensure full tag name is sent to the Tag instance
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnathonKoster committed Oct 19, 2024
1 parent 213f865 commit 46b011a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/View/Blade/Concerns/CompilesComponents.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ protected function compileComponent(ComponentNode $component): string
'params' => $params,
'content' => '',
'context' => [],
'tag' => '$tagName',
'tag' => '$fullTagName',
'tag_method' => $originalMethod,
]),
$tagMethod
Expand Down
2 changes: 1 addition & 1 deletion src/View/Blade/Concerns/CompilesPartials.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ protected function compilePartial(ComponentNode $component): string
'params' => $params,
'content' => '',
'context' => [],
'tag' => '$tagName',
'tag' => '$fullTagName',
'tag_method' => $originalMethod,
]), $tagMethod)->setIsPair($isPair)->setContent(base64_decode($__statamicResultVarSuffixTagContent))->render();
Expand Down
1 change: 1 addition & 0 deletions src/View/Blade/StatamicTagCompiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ protected function compileTemplate(ComponentNode $component, string $template, s
return (string) str($template)
->swap(array_merge([
'$tagName' => $name,
'$fullTagName' => $component->tagName,
'$tagMethod' => "'".$method."'",
'$originalMethod' => "'".$originalMethod."'",
'$params' => $this->attributeCompiler->compile($params),
Expand Down
19 changes: 19 additions & 0 deletions tests/View/Blade/AntlersComponents/ComponentCompilerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,4 +249,23 @@ public function it_allows_variables_to_be_updated()

$this->assertSame('4', trim(Blade::render($template)));
}

#[Test]
public function it_passes_full_tag_name()
{
(new class extends Tags
{
protected static $handle = 'my_tag';

public function wildcard()
{
return $this->tag;
}
})::register();

$this->assertSame(
'my_tag:the_method',
Blade::render('<s:my_tag:the_method />'),
);
}
}

0 comments on commit 46b011a

Please sign in to comment.