Skip to content

Commit

Permalink
add coding standard fixer for Twig templates
Browse files Browse the repository at this point in the history
  • Loading branch information
garak committed Jul 12, 2024
1 parent c39403f commit 59ba7be
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ jobs:
uses: actions/checkout@v4
- name: Fix CS
uses: docker://oskarstark/php-cs-fixer-ga
twig-cs-fixer:
runs-on: ubuntu-22.04
name: Twig-CS-Fixer
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Require the vendor
run: composer require --dev --no-update vincentlanglet/twig-cs-fixer ^2.12
- name: Update
run: composer update --no-interaction --no-progress
- name: Run
run: vendor/bin/twig-cs-fixer lint src/Knp/Menu/Resources/views
tests:
runs-on: ubuntu-22.04
strategy:
Expand Down
10 changes: 5 additions & 5 deletions src/Knp/Menu/Resources/views/knp_menu.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@
{% set currentItem = item %}
{# update the depth for children #}
{% if options.depth is not none %}
{% set options = options|merge({'depth': currentOptions.depth - 1}) %}
{% set options = options|merge({depth: currentOptions.depth - 1}) %}
{% endif %}
{# update the matchingDepth for children #}
{% if options.matchingDepth is not none and options.matchingDepth > 0 %}
{% set options = options|merge({'matchingDepth': currentOptions.matchingDepth - 1}) %}
{% set options = options|merge({matchingDepth: currentOptions.matchingDepth - 1}) %}
{% endif %}
{% for item in currentItem.children %}
{{ block('item') }}
Expand Down Expand Up @@ -75,7 +75,7 @@

{%- set attributes = item.attributes %}
{%- if classes is not empty %}
{%- set attributes = attributes|merge({'class': classes|join(' ')}) %}
{%- set attributes = attributes|merge({class: classes|join(' ')}) %}
{%- endif %}
{# displaying the item #}
{% import _self as knp_menu %}
Expand All @@ -85,10 +85,10 @@
{%- else %}
{{ block('spanElement') }}
{%- endif %}
{# render the list of children#}
{# render the list of children #}
{%- set childrenClasses = item.childrenAttribute('class') is not empty ? [item.childrenAttribute('class')] : [] %}
{%- set childrenClasses = childrenClasses|merge(['menu_level_' ~ item.level]) %}
{%- set listAttributes = item.childrenAttributes|merge({'class': childrenClasses|join(' ') }) %}
{%- set listAttributes = item.childrenAttributes|merge({class: childrenClasses|join(' ')}) %}
{{ block('list') }}
</li>
{% endif %}
Expand Down

0 comments on commit 59ba7be

Please sign in to comment.