Skip to content

Commit 623fe50

Browse files
committed
feature #2227 Add <twig:Turbo:Stream:*> components (nicolas-grekas)
This PR was squashed before being merged into the 2.x branch. Discussion ---------- Add `<twig:Turbo:Stream:*>` components | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | Issues | - | License | MIT This PR provides Twig components for turbo-streams: ```html <twig:Turbo:Stream:Append target="#some-id"> <div>Append this</div> </twig:Turbo:Stream:Append> ``` Sibling PR to #2196 See #2196 (comment) for some background. Commits ------- bfdbb46 CI love 356dbc2 Add `<twig:Turbo:Stream:*>` components
2 parents bca5384 + bfdbb46 commit 623fe50

17 files changed

+88
-53
lines changed

.github/workflows/test-turbo.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ on:
88
paths:
99
- 'src/Turbo/**'
1010

11+
env:
12+
SYMFONY_REQUIRE: '>=5.4'
13+
1114
jobs:
1215
phpstan:
1316
runs-on: ubuntu-latest
@@ -38,11 +41,11 @@ jobs:
3841
strategy:
3942
fail-fast: false
4043
matrix:
41-
php-version: ['8.1', '8.3']
44+
php-version: ['8.1', '8.4']
4245
include:
4346
- php-version: '8.1'
4447
dependency-version: 'lowest'
45-
- php-version: '8.3'
48+
- php-version: '8.4'
4649
dependency-version: 'highest'
4750

4851
services:
@@ -69,6 +72,9 @@ jobs:
6972
with:
7073
php-version: ${{ matrix.php-version }}
7174

75+
- name: Install symfony/flex
76+
run: composer global config allow-plugins.symfony/flex true && composer global require symfony/flex
77+
7278
- name: Install Turbo packages
7379
uses: ramsey/composer-install@v3
7480
with:
@@ -101,6 +107,8 @@ jobs:
101107

102108
- name: Run tests
103109
working-directory: src/Turbo
104-
run: vendor/bin/simple-phpunit
110+
run: |
111+
[ 'lowest' = '${{ matrix.dependency-version }}' ] && export SYMFONY_DEPRECATIONS_HELPER=weak
112+
vendor/bin/simple-phpunit
105113
env:
106114
SYMFONY_DEPRECATIONS_HELPER: 'max[self]=1'

src/Turbo/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- Add `Helper/TurboStream::append()` et al. methods
66
- Add `TurboStreamResponse`
7+
- Add `<twig:Turbo:Stream:*>` components
78

89
## 2.19.0
910

src/Turbo/composer.json

Lines changed: 1 addition & 0 deletions
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.21",
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",
Lines changed: 5 additions & 0 deletions
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>
Lines changed: 5 additions & 0 deletions
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>
Lines changed: 5 additions & 0 deletions
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>
Lines changed: 5 additions & 0 deletions
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>
Lines changed: 3 additions & 0 deletions
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>
Lines changed: 3 additions & 0 deletions
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>
Lines changed: 5 additions & 0 deletions
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>

0 commit comments

Comments
 (0)