Skip to content

Commit 509bae1

Browse files
committed
Add PostComponent and switch to component HTML syntax
1 parent e8a7547 commit 509bae1

File tree

13 files changed

+217
-132
lines changed

13 files changed

+217
-132
lines changed

composer.lock

Lines changed: 181 additions & 112 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/build/639.295ae6c2.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
File renamed without changes.

public/build/928.0e3059b2.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

public/build/app.09886d85.js renamed to public/build/app.22ced1a0.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/build/entrypoints.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
"js": [
55
"/build/runtime.5feae901.js",
66
"/build/41.64983f8e.js",
7-
"/build/928.0e3059b2.js",
8-
"/build/app.09886d85.js"
7+
"/build/639.295ae6c2.js",
8+
"/build/app.22ced1a0.js"
99
],
1010
"css": [
11-
"/build/928.76194c5a.css",
11+
"/build/639.76194c5a.css",
1212
"/build/app.3a149582.css"
1313
]
1414
},
@@ -27,9 +27,9 @@
2727
"integrity": {
2828
"/build/runtime.5feae901.js": "sha384-Dj9HEwBUNZIrIUOJJ4vOrf8e+X7fhJTYGYb0F/RJLrIo5qMTyh/mBApfQI4FmH8F",
2929
"/build/41.64983f8e.js": "sha384-XfOM8D6kvkEmauUMaczMxByKTBpbb9/aDqt1hPMgWDJh1X2ZQu5rIyRn3Ipx+rmn",
30-
"/build/928.0e3059b2.js": "sha384-KjnlXhwQ0i93knq1SMzG1q6DBwLVJszQEwEQQhCSkiWbtamCjJIwvE/EQf+Sj7tL",
31-
"/build/app.09886d85.js": "sha384-4l0f6J9YNcH3yqxVehcZCX4fNgWG3y3lvsGqK0kxdMJvcFUZwtauRSDYlL4PBLCJ",
32-
"/build/928.76194c5a.css": "sha384-PoA8WLGz/za3OOW7qjoDiv5f8mBVtREO35Z70PFH8PVIdu1+nWVUEetA6Q1o6DhV",
30+
"/build/639.295ae6c2.js": "sha384-4mr0Q0pZGcH1xnbq69bTTnnhMQCEAynmxjF0PPEnDngNgQKjPMqqCO2kx7UDIr68",
31+
"/build/app.22ced1a0.js": "sha384-zlbbpBjMsOQhWbu/y6oSuNjxPtxnQTuH2HP44M2WzqBeAGK7CZadXYlhsXsg3iD8",
32+
"/build/639.76194c5a.css": "sha384-PoA8WLGz/za3OOW7qjoDiv5f8mBVtREO35Z70PFH8PVIdu1+nWVUEetA6Q1o6DhV",
3333
"/build/app.3a149582.css": "sha384-nfrD0DNMpZazGQQAucFPYcE1VsR4Gg5Wut28sAVfEpTl6T5xVyF5D0qoc7GtumrW",
3434
"/build/384.af623ff4.js": "sha384-DTkf7hVvZ08YUepoH5wzP+thJm6maRzLe8KxUgIc2OajdJkoSDct0pJMEPYcEEeF",
3535
"/build/admin.747eb0c9.js": "sha384-vDe3FhM5HnWbM4nEdbmSv8AB5n/PfPJv0y0Goloka7w6jppc6di5LpKD1A252aFg",

public/build/manifest.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"build/app.css": "/build/app.3a149582.css",
3-
"build/app.js": "/build/app.09886d85.js",
3+
"build/app.js": "/build/app.22ced1a0.js",
44
"build/admin.css": "/build/admin.2b1a6c83.css",
55
"build/admin.js": "/build/admin.747eb0c9.js",
66
"build/runtime.js": "/build/runtime.5feae901.js",
77
"build/206.b003fa5f.js": "/build/206.b003fa5f.js",
88
"build/41.64983f8e.js": "/build/41.64983f8e.js",
9-
"build/928.76194c5a.css": "/build/928.76194c5a.css",
10-
"build/928.0e3059b2.js": "/build/928.0e3059b2.js",
9+
"build/639.76194c5a.css": "/build/639.76194c5a.css",
10+
"build/639.295ae6c2.js": "/build/639.295ae6c2.js",
1111
"build/630.ed629036.js": "/build/630.ed629036.js",
1212
"build/384.af623ff4.js": "/build/384.af623ff4.js",
1313
"build/images/fa-solid-900.svg": "/build/images/fa-solid-900.7a8b4f13.svg",

src/Twig/Components/PostComponent.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Twig\Components;
6+
7+
use App\Entity\Post;
8+
use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;
9+
10+
#[AsTwigComponent(name: 'post')]
11+
final class PostComponent
12+
{
13+
public Post $post;
14+
}

templates/blog/index.html.twig

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

55
{% block main %}
66
{% for post in paginator.results %}
7-
{{ include('blog/_post.html.twig') }}
7+
<twig:post :post="post"/>
88
{% else %}
99
<div class="jumbotron">{{ 'post.no_posts_found'|trans }}</div>
1010
{% endfor %}

templates/blog/search.html.twig

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@
44

55
{% block main %}
66
{#
7-
Render a component by passing its name as first argument
8-
See https://symfony.com/bundles/ux-twig-component/current/index.html
7+
Render a component by using the HTML syntax
8+
See https://symfony.com/bundles/ux-twig-component/current/index.html#component-html-syntax
99
#}
10-
{{ component('blog_search', {
11-
query: query
12-
}) }}
10+
<twig:blog_search :query="query"/>
1311
{% endblock %}
1412

1513
{% block sidebar %}

templates/components/blog_search.html.twig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@
1515
</div>
1616

1717
{% for post in this.posts %}
18-
{{ include('blog/_post.html.twig') }}
18+
{#
19+
You can nest components into another one
20+
See https://symfony.com/bundles/ux-twig-component/current/index.html#nested-components
21+
#}
22+
<twig:post :post="post"/>
1923
{% else %}
2024
{% if query is not empty %}
2125
{{ 'post.search_no_results'|trans }}

templates/blog/_post.html.twig renamed to templates/components/post.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<article class="post">
1+
<article{{ attributes.defaults({class: 'post'}) }}>
22
<h2>
33
<a href="{{ path('blog_post', {slug: post.slug}) }}">
44
{{ post.title }}

0 commit comments

Comments
 (0)