File tree Expand file tree Collapse file tree 4 files changed +34
-0
lines changed
templates/components/foo/bar Expand file tree Collapse file tree 4 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -190,6 +190,13 @@ as the second argument to the ``AsTwigComponent`` attribute:
190
190
// ...
191
191
}
192
192
193
+ Twig Template Namespaces
194
+ ~~~~~~~~~~~~~~~~~~~~~~~~
195
+
196
+ You can use a ``/ `` in your component's name to indicate a template namespace.
197
+ For example, a component with the name ``form/input `` will look for a template
198
+ in ``templates/components/form/input.html.twig ``.
199
+
193
200
The mount() Method
194
201
~~~~~~~~~~~~~~~~~~
195
202
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony \UX \TwigComponent \Tests \Fixtures \Component ;
13
+
14
+ use Symfony \UX \TwigComponent \Attribute \AsTwigComponent ;
15
+
16
+ #[AsTwigComponent('foo/bar/baz ' )]
17
+ final class NamespacedComponent
18
+ {
19
+ }
Original file line number Diff line number Diff line change
1
+ Content...
Original file line number Diff line number Diff line change @@ -130,6 +130,13 @@ public function testCanRenderEmbeddedComponent(): void
130
130
$ this ->assertStringContainsString ('custom td (1) ' , $ output );
131
131
}
132
132
133
+ public function testComponentWithNamespace (): void
134
+ {
135
+ $ output = $ this ->renderComponent ('foo/bar/baz ' );
136
+
137
+ $ this ->assertStringContainsString ('Content... ' , $ output );
138
+ }
139
+
133
140
private function renderComponent (string $ name , array $ data = []): string
134
141
{
135
142
return self ::getContainer ()->get (Environment::class)->render ('render_component.html.twig ' , [
You can’t perform that action at this time.
0 commit comments