Skip to content

Commit 19950bb

Browse files
committed
fix: docs.example
1 parent 31a74c5 commit 19950bb

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

templates/twig-component/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,29 @@ Use any HTML element as a Twig Component:
5454
<twig:Input type="email" name="email" required />
5555
```
5656

57+
### Use in anonymous Twig Components
58+
```twig
59+
{# templates/components/Teaser.html.twig #}
60+
<twig:Div class="teaser">
61+
<twig:H3>{{ headline }}</twig:H3>
62+
<twig:P>{{ content }}</twig:P>
63+
<twig:A role="button" href="{{ buttonLink }}" title="{{ buttonText }}">{{ buttonText }}</twig:A>
64+
</twig:Div>
65+
```
66+
67+
which can then be used in pages:
68+
```twig
69+
{# templates/page.html.twig #}
70+
{% for item in teasers %}
71+
<twig:Teaser
72+
headline="{{ item.headline }}"
73+
content="{{ item.content }}"
74+
buttonLink="{{ item.buttonLink }}"
75+
buttonText="{{ item.buttonText }}">
76+
</twig:Teaser>
77+
{% endfor %}
78+
```
79+
5780
## Features
5881

5982
- ✅ All HTML5 elements supported

0 commit comments

Comments
 (0)