Skip to content

Commit

Permalink
refactor: fix deprecated Twig code
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudLigny committed Dec 3, 2024
1 parent 9079d6c commit 7b4ce7f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion resources/layouts/partials/metatags.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
} -%}
{% endif %}
{# image #}
{% if (image is not defined or image is empty) and page.metatags.image.enabled ?? site.metatags.image.enabled ?? true %}
{% if (image is not defined or image is empty) and (page.metatags.image.enabled ?? site.metatags.image.enabled ?? true) %}
{%- set image = page.image|default(site.image|default()) %}
{% endif %}
{# video #}
Expand Down
2 changes: 1 addition & 1 deletion resources/layouts/partials/navigation.html.twig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{%- if menu|length > 1 ~%}
<nav>
<ol>
{%- for item in attribute(site.menus, menu)|sort_by_weight ~%}
{%- for item in site.menus[menu]|sort_by_weight ~%}
<li><a href="{{ url(item.url) }}">{{ item.name }}</a></li>
{%- endfor ~%}
</ol>
Expand Down
4 changes: 2 additions & 2 deletions resources/layouts/partials/terms-list.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<ul>
{%- for vocab in vocabs ~%}
{%- set vocabulary = vocab.id ~%}
{%- if attribute(page, vocabulary) is defined ~%}
{%- for term in attribute(page, vocabulary) ~%}
{%- if page[vocabulary] is defined ~%}
{%- for term in page[vocabulary] ~%}
<li><a class="term" href="{{ url(vocabulary ~ '/' ~ term, {language: site.language}) }}">{{ term }}</a></li>
{%- endfor ~%}
{%- endif ~%}
Expand Down
7 changes: 4 additions & 3 deletions src/Renderer/Extension/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
use Symfony\Component\VarDumper\Dumper\HtmlDumper;
use Symfony\Component\Yaml\Exception\ParseException;
use Symfony\Component\Yaml\Yaml;
use Twig\DeprecatedCallableInfo;

/**
* Class Renderer\Extension\Core.
Expand Down Expand Up @@ -90,17 +91,17 @@ public function getFunctions()
new \Twig\TwigFunction(
'hash',
[$this, 'integrity'],
['deprecated' => true, 'alternative' => 'integrity']
['deprecation_info' => new DeprecatedCallableInfo('Cecil', '8.0', 'integrity')]
),
new \Twig\TwigFunction(
'minify',
[$this, 'minify'],
['deprecated' => true, 'alternative' => 'minify filter']
['deprecation_info' => new DeprecatedCallableInfo('Cecil', '8.0', 'minify filter')]
),
new \Twig\TwigFunction(
'toCSS',
[$this, 'toCss'],
['deprecated' => true, 'alternative' => 'to_css filter']
['deprecation_info' => new DeprecatedCallableInfo('Cecil', '8.0', 'to_css filter')]
),
];
}
Expand Down

0 comments on commit 7b4ce7f

Please sign in to comment.