Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Maker/MakeTwigComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function configureCommand(Command $command, InputConfiguration $inputConf
{
$command
->setDescription(self::getCommandDescription())
->addArgument('name', InputArgument::OPTIONAL, 'The name of your twig component (ie <fg=yellow>NotificationComponent</>)')
->addArgument('name', InputArgument::OPTIONAL, 'The name of your twig component (ie <fg=yellow>Notification</>)')
->addOption('live', null, InputOption::VALUE_NONE, 'Whether to create a live twig component (requires <fg=yellow>symfony/ux-live-component</>)')
;
}
Expand Down Expand Up @@ -84,7 +84,7 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen

$this->writeSuccessMessage($io);
$io->newLine();
$io->writeln(" To render the component, use {{ component('{$shortName}') }}.");
$io->writeln(" To render the component, use <fg=yellow><twig:{$shortName} /></>.");
$io->newLine();
}

Expand Down
2 changes: 1 addition & 1 deletion src/Resources/skeleton/twig/Component.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;

#[AsTwigComponent()]
#[AsTwigComponent]
final class <?= $class_name."\n" ?>
{
}
2 changes: 1 addition & 1 deletion src/Resources/skeleton/twig/LiveComponent.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
use Symfony\UX\LiveComponent\DefaultActionTrait;

#[AsLiveComponent()]
#[AsLiveComponent]
final class <?= $class_name."\n" ?>
{
use DefaultActionTrait;
Expand Down
8 changes: 4 additions & 4 deletions tests/Maker/MakeTwigComponentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function getTestDetails(): \Generator

$this->assertStringContainsString('src/Twig/Components/Alert.php', $output);
$this->assertStringContainsString('templates/components/Alert.html.twig', $output);
$this->assertStringContainsString("To render the component, use {{ component('Alert') }}.", $output);
$this->assertStringContainsString('To render the component, use <twig:Alert />.', $output);

$runner->copy(
'make-twig-component/tests/it_generates_twig_component.php',
Expand All @@ -46,7 +46,7 @@ public function getTestDetails(): \Generator

$this->assertStringContainsString('src/Twig/Components/FormInput.php', $output);
$this->assertStringContainsString('templates/components/FormInput.html.twig', $output);
$this->assertStringContainsString("To render the component, use {{ component('FormInput') }}.", $output);
$this->assertStringContainsString('To render the component, use <twig:FormInput />.', $output);

$runner->copy(
'make-twig-component/tests/it_generates_twig_component.php',
Expand All @@ -65,7 +65,7 @@ public function getTestDetails(): \Generator

$this->assertStringContainsString('src/Twig/Components/Alert.php', $output);
$this->assertStringContainsString('templates/components/Alert.html.twig', $output);
$this->assertStringContainsString("To render the component, use {{ component('Alert') }}.", $output);
$this->assertStringContainsString('To render the component, use <twig:Alert />.', $output);

$runner->copy(
'make-twig-component/tests/it_generates_live_component.php',
Expand All @@ -84,7 +84,7 @@ public function getTestDetails(): \Generator

$this->assertStringContainsString('src/Twig/Components/FormInput.php', $output);
$this->assertStringContainsString('templates/components/FormInput.html.twig', $output);
$this->assertStringContainsString("To render the component, use {{ component('FormInput') }}.", $output);
$this->assertStringContainsString('To render the component, use <twig:FormInput />.', $output);

$runner->copy(
'make-twig-component/tests/it_generates_live_component.php',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class GeneratedTwigComponentTest extends KernelTestCase
{
public function testController()
{
$output = self::getContainer()->get('twig')->createTemplate("{{ component('{name}') }}")->render();
$output = self::getContainer()->get('twig')->createTemplate("<twig:{name} />")->render();

$this->assertStringContainsString('<div data-controller="live"', $output);
$this->assertStringContainsString('data-live-name-value="', $output);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class GeneratedTwigComponentTest extends KernelTestCase
{
public function testController()
{
$output = self::getContainer()->get('twig')->createTemplate("{{ component('{name}') }}")->render();
$output = self::getContainer()->get('twig')->createTemplate("<twig:{name} />")->render();

$this->assertSame("<div>\n <!-- component html -->\n</div>\n", $output);
}
Expand Down