Skip to content
Open
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
2 changes: 1 addition & 1 deletion src/TwigComponent/src/Test/InteractsWithTwigComponents.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected function renderTwigComponent(string $name, array $data = [], ?string $
$template = \sprintf('{%% component "%s" with data %%}', addslashes($name));

foreach (array_keys($blocks) as $blockName) {
$template .= \sprintf('{%% block %1$s %%}{{ blocks.%1$s|raw }}{%% endblock %%}', $blockName);
$template .= \sprintf('{%% block %1$s %%}{{ outerScope.blocks.%1$s|raw }}{%% endblock %%}', $blockName);
}

$template .= '{% endcomponent %}';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\UX\TwigComponent\Tests\Fixtures\Component;

use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;

/**
* @author Kevin Bond <kevinbond@gmail.com>
*/
#[AsTwigComponent]
final class WithSlotsAndLimitedScope
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div>
{% with { outerScope } only %}
{% block content %}{% endblock %}
{% block slot1 %}{% endblock %}
{% block slot2 %}{% endblock %}
{% endwith %}
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public function testCannotGetConfigByNameForNonRegisteredComponent()
* @testWith ["tabl", "Unknown component \"tabl\". Did you mean this: \"table\"?"]
* ["Basic", "Unknown component \"Basic\". Did you mean this: \"BasicComponent\"?"]
* ["basic", "Unknown component \"basic\". Did you mean this: \"BasicComponent\"?"]
* ["with", "Unknown component \"with\". Did you mean one of these: \"with_attributes\", \"with_exposed_variables\", \"WithSlots\"?"]
* ["with", "Unknown component \"with\". Did you mean one of these: \"with_attributes\", \"with_exposed_variables\", \"WithSlots\", \"WithSlotsAndLimitedScope\"?"]
* ["anonAnon", "Unknown component \"anonAnon\". And no matching anonymous component template was found."]
*/
public function testCannotGetInvalidComponent(string $name, string $expectedExceptionMessage)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Symfony\UX\TwigComponent\Test\InteractsWithTwigComponents;
use Symfony\UX\TwigComponent\Tests\Fixtures\Component\ComponentA;
use Symfony\UX\TwigComponent\Tests\Fixtures\Component\WithSlots;
use Symfony\UX\TwigComponent\Tests\Fixtures\Component\WithSlotsAndLimitedScope;
use Symfony\UX\TwigComponent\Tests\Fixtures\Service\ServiceA;

final class InteractsWithTwigComponentsTest extends KernelTestCase
Expand Down Expand Up @@ -87,5 +88,7 @@ public static function withSlotsNameProvider(): iterable
{
yield ['WithSlots'];
yield [WithSlots::class];
yield ['WithSlotsAndLimitedScope'];
yield [WithSlotsAndLimitedScope::class];
}
}
Loading