Skip to content

Commit add0a14

Browse files
seb-jeanKocal
authored andcommitted
[Turbo] Add <Turbo:Frame> component
1 parent c2cc9f0 commit add0a14

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## 2.22.0
44

55
- Add `<twig:Turbo:Stream>` component
6+
- Add `<twig:Turbo:Frame>` component
67

78
## 2.21.0
89

doc/index.rst

+38
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,44 @@ a Turbo Frame, and retrieve the ID of this frame::
250250
}
251251
}
252252

253+
<twig:Turbo:Frame> Twig Component
254+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
255+
256+
.. versionadded:: 2.22
257+
258+
The ``<twig:Turbo:Frame>`` Twig Component was added in Turbo 2.22.
259+
260+
Simple example:
261+
262+
.. code-block:: html+twig
263+
264+
<twig:Turbo:Frame id="the_frame_id" />
265+
266+
{# renders as: #}
267+
<turbo-frame id="the_frame_id"></turbo-frame>
268+
269+
With a HTML attribute:
270+
271+
.. code-block:: html+twig
272+
273+
<twig:Turbo:Frame id="the_frame_id" loading="lazy" src="{{ path('block') }}" />
274+
275+
{# renders as: #}
276+
<turbo-frame id="the_frame_id" loading="lazy" src="https://example.com/block"></turbo-frame>
277+
278+
With content:
279+
280+
.. code-block:: html+twig
281+
282+
<twig:Turbo:Frame id="the_frame_id" src="{{ path('block') }}">
283+
A placeholder.
284+
</twig:Turbo:Frame>
285+
286+
{# renders as: #}
287+
<turbo-frame id="the_frame_id" src="https://example.com/block">
288+
A placeholder.
289+
</turbo-frame>
290+
253291
Writing Tests
254292
^^^^^^^^^^^^^
255293

templates/components/Frame.html.twig

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{% props id -%}
2+
3+
<turbo-frame id="{{ id }}" {{- attributes }}>
4+
{%- block content %}{% endblock -%}
5+
</turbo-frame>

0 commit comments

Comments
 (0)