Skip to content

Commit 2fa8803

Browse files
Add <twig:Turbo:Stream:*> components
1 parent d72aa7e commit 2fa8803

15 files changed

+73
-50
lines changed

src/Turbo/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# CHANGELOG
22

3+
## 2.20.0
4+
5+
- Add `<twig:Turbo:Stream:*>` components
6+
37
## 2.19.0
48

59
- Fix Doctrine proxies are not Broadcasted #3139

src/Turbo/composer.json

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"symfony/property-access": "^5.4|^6.0|^7.0",
5353
"symfony/security-core": "^5.4|^6.0|^7.0",
5454
"symfony/stopwatch": "^5.4|^6.0|^7.0",
55+
"symfony/ux-twig-component": "^2.0",
5556
"symfony/twig-bundle": "^5.4|^6.0|^7.0",
5657
"symfony/web-profiler-bundle": "^5.4|^6.0|^7.0",
5758
"symfony/webpack-encore-bundle": "^2.1.1",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{% props target -%}
2+
3+
<turbo-stream action="after" targets="{{ target }}" {{ attributes }}>
4+
<template>{% block content %}{% endblock %}</template>
5+
</turbo-stream>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{% props target -%}
2+
3+
<turbo-stream action="append" targets="{{ target }}" {{ attributes }}>
4+
<template>{% block content %}{% endblock %}</template>
5+
</turbo-stream>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{% props target -%}
2+
3+
<turbo-stream action="before" targets="{{ target }}" {{ attributes }}>
4+
<template>{% block content %}{% endblock %}</template>
5+
</turbo-stream>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{% props target -%}
2+
3+
<turbo-stream action="prepend" targets="{{ target }}" {{ attributes }}>
4+
<template>{% block content %}{% endblock %}</template>
5+
</turbo-stream>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{% props requestId = null -%}
2+
3+
<turbo-stream action="refresh"{% if requestId is not null %} request-id="{{ requestId }}"{% endif %} {{ attributes }}></turbo-stream>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{% props target -%}
2+
3+
<turbo-stream action="remove" targets="{{ target }}" {{ attributes }}></turbo-stream>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{% props target, morph = false -%}
2+
3+
<turbo-stream action="replace" targets="{{ target }}"{% if morph %} method="morph"{% endif %} {{ attributes }}>
4+
<template>{% block content %}{% endblock %}</template>
5+
</turbo-stream>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{% props target, morph = false -%}
2+
3+
<turbo-stream action="update" targets="{{ target }}"{% if morph %} method="morph"{% endif %} {{ attributes }}>
4+
<template>{% block content %}{% endblock %}</template>
5+
</turbo-stream>
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
{% block create %}
2-
<turbo-stream action="append" target="artists">
3-
<template>
4-
<div id="{{ 'artist_' ~ id }}"><a href="{{ path('artist', {id: id}) }}">{{ entity.name }} (#{{ id }})</a></div>
5-
</template>
6-
</turbo-stream>
2+
<twig:Turbo:Stream:Append target="#artists">
3+
<div id="{{ 'artist_' ~ id }}"><a href="{{ path('artist', {id: id}) }}">{{ entity.name }} (#{{ id }})</a></div>
4+
</twig:Turbo:Stream:Append>
75
{% endblock %}
86

97
{% block update %}
10-
<turbo-stream action="update" target="artist_{{ id }}">
11-
<template>
12-
{{ entity.name }} (#{{ id }}, updated)
13-
</template>
14-
</turbo-stream>
8+
<twig:Turbo:Stream:Update target="#artist_{{ id }}">
9+
{{ entity.name }} (#{{ id }}, updated)
10+
</twig:Turbo:Stream:Update>
1511
{% endblock %}
1612

1713
{% block remove %}
18-
<turbo-stream action="remove" target="artist_{{ id }}"></turbo-stream>
14+
<twig:Turbo:Stream:Remove target="#artist_{{ id }}"></twig:Turbo:Stream:Remove>
1915
{% endblock %}
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
{% block create %}
2-
<turbo-stream action="append" target="books">
3-
<template>
4-
<div id="{{ 'book_' ~ id }}">{{ entity.title }} (#{{ id }})</div>
5-
</template>
6-
</turbo-stream>
2+
<twig:Turbo:Stream:Append target="#books">
3+
<div id="{{ 'book_' ~ id }}">{{ entity.title }} (#{{ id }})</div>
4+
</twig:Turbo:Stream:Append>
75
{% endblock %}
86

97
{% block update %}
10-
<turbo-stream action="update" target="book_{{ id }}">
11-
<template>
12-
{{ entity.title }} (#{{ id }}, updated)
13-
</template>
14-
</turbo-stream>
8+
<twig:Turbo:Stream:Update target="#book_{{ id }}">
9+
{{ entity.title }} (#{{ id }}, updated)
10+
</twig:Turbo:Stream:Update>
1511
{% endblock %}
1612

1713
{% block remove %}
18-
<turbo-stream action="remove" target="book_{{ id }}"></turbo-stream>
14+
<twig:Turbo:Stream:Remove target="#book_{{ id }}"></twig:Turbo:Stream:Remove>
1915
{% endblock %}
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
{% block create %}
2-
<turbo-stream action="append" target="songs">
3-
<template>
4-
<div id="{{ 'song_' ~ id }}">{{ entity.title }} (#{{ id }}){% if entity.artist %} by {{ entity.artist.name }} (#{{ entity.artist.id }}){% endif %}</div>
5-
</template>
6-
</turbo-stream>
2+
<twig:Turbo:Stream:Append target="#songs">
3+
<div id="{{ 'song_' ~ id }}">{{ entity.title }} (#{{ id }}){% if entity.artist %} by {{ entity.artist.name }} (#{{ entity.artist.id }}){% endif %}</div>
4+
</twig:Turbo:Stream:Append>
75
{% endblock %}
86

97
{% block update %}
10-
<turbo-stream action="update" target="song_{{ id }}">
11-
<template>
12-
{{ entity.title }} (#{{ id }}, updated)
13-
</template>
14-
</turbo-stream>
8+
<twig:Turbo:Stream:Update target="#song_{{ id }}">
9+
{{ entity.title }} (#{{ id }}, updated)
10+
</twig:Turbo:Stream:Update>
1511
{% endblock %}
1612

1713
{% block remove %}
18-
<turbo-stream action="remove" target="song_{{ id }}"></turbo-stream>
14+
<twig:Turbo:Stream:Remove target="#song_{{ id }}"></twig:Turbo:Stream:Remove>
1915
{% endblock %}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
<turbo-stream action="append" target="messages">
2-
<template>
3-
<div>{{ message }}</div>
4-
</template>
5-
</turbo-stream>
1+
<twig:Turbo:Stream:Append target="#messages">
2+
<div>{{ message }}</div>
3+
</twig:Turbo:Stream:Append>
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
<turbo-stream action="replace" target="form">
2-
<template>
3-
<div id="form">
4-
This div replaces the existing element with the DOM ID "form".
5-
</div>
6-
</template>
7-
</turbo-stream>
1+
<twig:Turbo:Stream:Replace target="#form">
2+
<div id="form">
3+
This div replaces the existing element with the DOM ID "form".
4+
</div>
5+
</twig:Turbo:Stream:Replace>
86

9-
<turbo-stream action="append" target="another_block">
10-
<template>
11-
<div>Appended!</div>
12-
</template>
13-
</turbo-stream>
7+
<twig:Turbo:Stream:Append target="#another_block">
8+
<div>Appended!</div>
9+
</twig:Turbo:Stream:Append>

0 commit comments

Comments
 (0)