Skip to content

Commit e28fadc

Browse files
committed
minor #1601 [Twig] Update the doc blocks (rosier)
This PR was merged into the main branch. Discussion ---------- [Twig] Update the doc blocks This makes the formatting of the doc blocks a bit more consistent Commits ------- 2f268df Update twig doc blocks
2 parents ea6a56f + 2f268df commit e28fadc

File tree

8 files changed

+59
-45
lines changed

8 files changed

+59
-45
lines changed

templates/admin/blog/index.html.twig

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717
{% for post in posts %}
1818
<tr>
1919
<td>{{ post.title }}</td>
20-
{# it's not mandatory to set the timezone in localizeddate(). This is done to
21-
avoid errors when the 'intl' PHP extension is not available and the application
22-
is forced to use the limited "intl polyfill", which only supports UTC and GMT #}
20+
{#
21+
It's not mandatory to set the timezone in format_datetime(). This is done to
22+
avoid errors when the 'intl' PHP extension is not available and the application
23+
is forced to use the limited "intl polyfill", which only supports UTC and GMT
24+
#}
2325
<td>{{ post.publishedAt|format_datetime('medium', 'short', '', 'UTC') }}</td>
2426
<td class="text-right">
2527
<div class="item-actions">

templates/admin/layout.html.twig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{#
2-
This is the base template of the all backend pages. Since this layout is similar
3-
to the global layout, we inherit from it to just change the contents of some
4-
blocks. In practice, backend templates are using a three-level inheritance,
5-
showing how powerful, yet easy to use, is Twig's inheritance mechanism.
6-
See https://symfony.com/doc/current/templates.html#template-inheritance-and-layouts
2+
This is the base template of the all backend pages. Since this layout is similar
3+
to the global layout, we inherit from it to just change the contents of some
4+
blocks. In practice, backend templates are using a three-level inheritance,
5+
showing how powerful, yet easy to use, is Twig's inheritance mechanism.
6+
See https://symfony.com/doc/current/templates.html#template-inheritance-and-layouts
77
#}
88
{% extends 'base.html.twig' %}
99

templates/base.html.twig

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{#
2-
This is the base template used as the application layout which contains the
3-
common elements and decorates all the other templates.
4-
See https://symfony.com/doc/current/templates.html#template-inheritance-and-layouts
2+
This is the base template used as the application layout which contains the
3+
common elements and decorates all the other templates.
4+
See https://symfony.com/doc/current/templates.html#template-inheritance-and-layouts
55
#}
66
<!DOCTYPE html>
77
<html lang="{{ app.locale }}" dir="{{ is_rtl() ? 'rtl' : 'ltr' }}">
@@ -132,9 +132,11 @@
132132
</footer>
133133
{% endblock %}
134134

135-
{# it's not mandatory to set the timezone in localizeddate(). This is done to
136-
avoid errors when the 'intl' PHP extension is not available and the application
137-
is forced to use the limited "intl polyfill", which only supports UTC and GMT #}
135+
{#
136+
It's not mandatory to set the timezone in format_datetime(). This is done to
137+
avoid errors when the 'intl' PHP extension is not available and the application
138+
is forced to use the limited "intl polyfill", which only supports UTC and GMT
139+
#}
138140
<!-- Page rendered on {{ 'now'|format_datetime('long', 'long', '', 'UTC') }} -->
139141
</body>
140142
</html>

templates/blog/_comment_form.html.twig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
#}
88

99
{{ form_start(form, {method: 'POST', action: path('comment_new', {'postSlug': post.slug})}) }}
10-
{# instead of displaying form fields one by one, you can also display them
10+
{#
11+
Instead of displaying form fields one by one, you can also display them
1112
all with their default options and styles just by calling to this function:
1213
1314
{{ form_widget(form) }}

templates/blog/about.html.twig

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
</div>
1010
</div>
1111

12-
{# it's not mandatory to set the timezone in localizeddate(). This is done to
13-
avoid errors when the 'intl' PHP extension is not available and the application
14-
is forced to use the limited "intl polyfill", which only supports UTC and GMT #}
12+
{#
13+
It's not mandatory to set the timezone in format_datetime(). This is done to
14+
avoid errors when the 'intl' PHP extension is not available and the application
15+
is forced to use the limited "intl polyfill", which only supports UTC and GMT
16+
#}
1517
<!-- Fragment rendered on {{ 'now'|format_datetime('long', 'long', '', 'UTC') }} -->

templates/blog/post_show.html.twig

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,18 @@
1515
{{ include('blog/_post_tags.html.twig') }}
1616

1717
<div id="post-add-comment" class="well">
18-
{# The 'IS_AUTHENTICATED_FULLY' role ensures that the user has entered
19-
their credentials (login + password) during this session. If they
20-
are automatically logged via the 'Remember Me' functionality, they won't
21-
be able to add a comment.
22-
See https://symfony.com/doc/current/security/remember_me.html#forcing-the-user-to-re-authenticate-before-accessing-certain-resources
18+
{#
19+
The 'IS_AUTHENTICATED_FULLY' role ensures that the user has entered
20+
their credentials (login + password) during this session. If they
21+
are automatically logged via the 'Remember Me' functionality, they won't
22+
be able to add a comment.
23+
See https://symfony.com/doc/current/security/remember_me.html#forcing-the-user-to-re-authenticate-before-accessing-certain-resources
2324
#}
2425
{% if is_granted('IS_AUTHENTICATED_FULLY') %}
25-
{# when the name of the Twig argument is the same as the name of the variable, you can omit it.
26-
e.g. instead of controller('...', {post: post}) you can use controller('...', {post}) #}
26+
{#
27+
When the name of the Twig argument is the same as the name of the variable, you can omit it.
28+
e.g. instead of controller('...', {post: post}) you can use controller('...', {post})
29+
#}
2730
{{ render(controller('App\\Controller\\BlogController::commentForm', {post})) }}
2831
{% else %}
2932
<p>
@@ -44,9 +47,11 @@
4447
<a name="comment_{{ comment.id }}"></a>
4548
<h4 class="col-sm-3">
4649
<strong>{{ comment.author.fullName }}</strong> {{ 'post.commented_on'|trans }}
47-
{# it's not mandatory to set the timezone in localizeddate(). This is done to
48-
avoid errors when the 'intl' PHP extension is not available and the application
49-
is forced to use the limited "intl polyfill", which only supports UTC and GMT #}
50+
{#
51+
It's not mandatory to set the timezone in format_datetime(). This is done to
52+
avoid errors when the 'intl' PHP extension is not available and the application
53+
is forced to use the limited "intl polyfill", which only supports UTC and GMT
54+
#}
5055
<strong>{{ comment.publishedAt|format_datetime('medium', 'short', '', 'UTC') }}</strong>
5156
</h4>
5257
<div class="col-sm-9">
@@ -69,9 +74,11 @@
6974
</div>
7075
{% endif %}
7176

72-
{# the parent() function includes the contents defined by the parent template
73-
('base.html.twig') for this block ('sidebar'). This is a very convenient way
74-
to share common contents in different templates #}
77+
{#
78+
The parent() function includes the contents defined by the parent template
79+
('base.html.twig') for this block ('sidebar'). This is a very convenient way
80+
to share common contents in different templates
81+
#}
7582
{{ parent() }}
7683

7784
{{ show_source_code(_self) }}

templates/default/_flash_messages.html.twig

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
{#
2-
This is a template fragment designed to be included in other templates
3-
See https://symfony.com/doc/current/templates.html#including-templates
2+
This is a template fragment designed to be included in other templates
3+
See https://symfony.com/doc/current/templates.html#including-templates
44
5-
A common practice to better distinguish between templates and fragments is to
6-
prefix fragments with an underscore. That's why this template is called
7-
'_flash_messages.html.twig' instead of 'flash_messages.html.twig'
5+
A common practice to better distinguish between templates and fragments is to
6+
prefix fragments with an underscore. That's why this template is called
7+
'_flash_messages.html.twig' instead of 'flash_messages.html.twig'
88
#}
99

1010
{#
11-
The check is needed to prevent starting the session when looking for "flash messages":
12-
https://symfony.com/doc/current/session.html#avoid-starting-sessions-for-anonymous-users
11+
The check is needed to prevent starting the session when looking for "flash messages":
12+
https://symfony.com/doc/current/session.html#avoid-starting-sessions-for-anonymous-users
1313
14-
TIP: With FOSHttpCache you can also adapt this to make it cache safe:
15-
https://foshttpcachebundle.readthedocs.io/en/latest/features/helpers/flash-message.html
14+
TIP: With FOSHttpCache you can also adapt this to make it cache safe:
15+
https://foshttpcachebundle.readthedocs.io/en/latest/features/helpers/flash-message.html
1616
#}
1717
{% if app.request.hasPreviousSession %}
1818
<div class="messages">

templates/form/fields.html.twig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{#
2-
Each field type is rendered by a template fragment, which is determined
3-
by the name of your form type class (DateTimePickerType -> date_time_picker)
4-
and the suffix "_widget". This can be controlled by overriding getBlockPrefix()
5-
in DateTimePickerType.
2+
Each field type is rendered by a template fragment, which is determined
3+
by the name of your form type class (DateTimePickerType -> date_time_picker)
4+
and the suffix "_widget". This can be controlled by overriding getBlockPrefix()
5+
in DateTimePickerType.
66
7-
See https://symfony.com/doc/current/form/create_custom_field_type.html#creating-the-form-type-template
7+
See https://symfony.com/doc/current/form/create_custom_field_type.html#creating-the-form-type-template
88
#}
99

1010
{% block date_time_picker_widget %}

0 commit comments

Comments
 (0)