Skip to content

Commit eec413c

Browse files
committed
1322: Applied Twig coding standards
1 parent d2f5585 commit eec413c

File tree

78 files changed

+219
-186
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+219
-186
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,3 +201,4 @@ yarn-error.log
201201
.DS_Store
202202

203203
.env*.local
204+
.twig-cs-fixer.cache

.twig-cs-fixer.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
// @see https://github.com/VincentLanglet/Twig-CS-Fixer/blob/main/docs/configuration.md#standard
4+
$config = new TwigCsFixer\Config\Config();
5+
6+
// @see https://github.com/VincentLanglet/Twig-CS-Fixer/pull/134#issuecomment-1756924889
7+
$config->addTokenParser(new Drupal\Core\Template\TwigTransTokenParser());
8+
9+
return $config;

composer.json

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@
6565
"drupal/core-dev": "^10.1",
6666
"drupal/devel": "^5.1",
6767
"ergebnis/composer-normalize": "^2.42",
68-
"friendsoftwig/twigcs": "^6.2",
6968
"kint-php/kint": "^5.0",
7069
"mglaman/phpstan-drupal": "^1.2",
7170
"os2loop/os2loop_fixtures": "*",
7271
"phpspec/prophecy-phpunit": "^2.0",
7372
"phpstan/extension-installer": "^1.3",
74-
"phpstan/phpstan-deprecation-rules": "^1.1"
73+
"phpstan/phpstan-deprecation-rules": "^1.1",
74+
"vincentlanglet/twig-cs-fixer": "^2.9"
7575
},
7676
"conflict": {
7777
"drupal/drupal": "*"
@@ -216,27 +216,31 @@
216216
],
217217
"coding-standards-apply": [
218218
"@coding-standards-apply/phpcs",
219+
"@coding-standards-apply/twig-cs-fixer",
219220
"@coding-standards-apply/composer-normalize"
220221
],
221222
"coding-standards-apply/composer-normalize": [
222-
"@normalize"
223+
"composer normalize"
223224
],
224225
"coding-standards-apply/phpcs": [
225226
"vendor/bin/phpcbf --standard=phpcs.xml.dist"
226227
],
228+
"coding-standards-apply/twig-cs-fixer": [
229+
"twig-cs-fixer lint --fix web/profiles/custom/os2loop/themes/os2loop_theme/templates"
230+
],
227231
"coding-standards-check": [
228232
"@coding-standards-check/phpcs",
229-
"@coding-standards-check/twigcs",
233+
"@coding-standards-check/twig-cs-fixer",
230234
"@coding-standards-check/composer-normalize"
231235
],
232236
"coding-standards-check/composer-normalize": [
233-
"@normalize --dry-run"
237+
"composer normalize --dry-run"
234238
],
235239
"coding-standards-check/phpcs": [
236240
"php vendor/bin/phpcs --standard=phpcs.xml.dist"
237241
],
238-
"coding-standards-check/twigcs": [
239-
"twigcs web/profiles/custom/os2loop/themes/os2loop_theme/templates"
242+
"coding-standards-check/twig-cs-fixer": [
243+
"twig-cs-fixer lint web/profiles/custom/os2loop/themes/os2loop_theme/templates"
240244
]
241245
}
242246
}

composer.lock

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

web/profiles/custom/os2loop/themes/os2loop_theme/templates/block/block--mainnavigation.html.twig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,3 @@
3737
{% block content %}
3838
{{ content }}
3939
{% endblock %}
40-
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{# Only select users can edit their account details #}
22
{% if is_granted('os2loop_user_manual') %}
3-
{% include 'container.html.twig' %}
3+
{{ include('container.html.twig') }}
44
{% endif %}

web/profiles/custom/os2loop/themes/os2loop_theme/templates/content-entities/comment--list-display.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
{% endif %}
8585
</div>
8686
<div class="d-flex mt-10 mb-0">
87-
<a href="{{ path('entity.comment.canonical', {'comment': comment.id}) }}#comment-{{ comment.id }}" class="link-unstyled">
87+
<a href="{{ path('entity.comment.canonical', {comment: comment.id}) }}#comment-{{ comment.id }}" class="link-unstyled">
8888
{% if comment_value_truncated %}
8989
{{ comment_value|truncate(200, true, '...')|raw }}
9090
{% else %}

web/profiles/custom/os2loop/themes/os2loop_theme/templates/content-entities/comment--os2loop-post-comments.html.twig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@
8787
indicator here would break the render cache.
8888
#}
8989
<div class="container entity-header d-inline-flex align-items-top">
90-
{% include '@os2loop_theme/field/user-info.html.twig' with {user: drupal_entity('user', comment.uid.target_id), date: created, entity: comment, attributes: attributes} %}
91-
{% include '@os2loop_theme/navigation/comment-tasks.html.twig' with {node: drupal_entity('node', comment.entity_id.target_id)} %}
90+
{{ include('@os2loop_theme/field/user-info.html.twig', {user: drupal_entity('user', comment.uid.target_id), date: created, entity: comment, attributes: attributes}) }}
91+
{{ include('@os2loop_theme/navigation/comment-tasks.html.twig', {node: drupal_entity('node', comment.entity_id.target_id)}) }}
9292
</div>
9393
{#
9494
Indicate the semantic relationship between parent and child comments for
@@ -104,7 +104,7 @@
104104
<p class="visually-hidden">{{ parent }}</p>
105105
<div class="parent-entity" aria-hidden="true">
106106
<div class="parent-entity-header row no-gutters mb-10">
107-
{% include '@os2loop_theme/field/user-info.html.twig' with {user: drupal_entity('user', parent_comment.uid.target_id), date: parent_created, entity: parent_comment, attributes: null} %}
107+
{{ include('@os2loop_theme/field/user-info.html.twig', {user: drupal_entity('user', parent_comment.uid.target_id), date: parent_created, entity: parent_comment, attributes: null}) }}
108108
</div>
109109
<div class="parent-entity-body{{ toggle_parent_comment ? ' collapse' }}" id="parent-entity-body-{{ parent_comment.id() }}">
110110
{{ parent_comment.os2loop_post_comment.value }}

web/profiles/custom/os2loop/themes/os2loop_theme/templates/content-entities/comment--os2loop-question-answers.html.twig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@
8787
indicator here would break the render cache.
8888
#}
8989
<div class="container entity-header d-inline-flex align-items-top">
90-
{% include '@os2loop_theme/field/user-info.html.twig' with {user: drupal_entity('user', comment.uid.target_id), date: created, entity: comment, attributes: attributes} %}
91-
{% include '@os2loop_theme/navigation/comment-tasks.html.twig' with {node: drupal_entity('node', comment.entity_id.target_id)} %}
90+
{{ include('@os2loop_theme/field/user-info.html.twig', {user: drupal_entity('user', comment.uid.target_id), date: created, entity: comment, attributes: attributes}) }}
91+
{{ include('@os2loop_theme/navigation/comment-tasks.html.twig', {node: drupal_entity('node', comment.entity_id.target_id)}) }}
9292
</div>
9393
{#
9494
Indicate the semantic relationship between parent and child comments for
@@ -104,7 +104,7 @@
104104
<p class="visually-hidden">{{ parent }}</p>
105105
<div class="parent-entity" aria-hidden="true">
106106
<div class="parent-entity-header row no-gutters mb-10">
107-
{% include '@os2loop_theme/field/user-info.html.twig' with {user: drupal_entity('user', parent_comment.uid.target_id), date: parent_created, entity: parent_comment, attributes: null} %}
107+
{{ include('@os2loop_theme/field/user-info.html.twig', {user: drupal_entity('user', parent_comment.uid.target_id), date: parent_created, entity: parent_comment, attributes: null}) }}
108108
</div>
109109
<div class="parent-entity-body{{ toggle_parent_comment ? ' collapse' }}" id="parent-entity-body-{{ parent_comment.id() }}">
110110
{{ parent_comment.os2loop_question_answer.value }}

web/profiles/custom/os2loop/themes/os2loop_theme/templates/content-entities/comment--view--os2loop-search-db.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% set content_url = path('entity.node.canonical', {'node': commented_entity.id}) %}
1+
{% set content_url = path('entity.node.canonical', {node: commented_entity.id}) %}
22
{% set comment_url = content_url ~ '#comment-' ~ comment.id %}
33

44
<div class="my-3 search-result search-result--comment search-result--comment--{{ comment.bundle }}">

0 commit comments

Comments
 (0)