{
  "version": "https://jsonfeed.org/version/1.1",
  "title": "Cecil - Fonctions et filtres",
  "home_page_url": "https://cloudflare.cecil.app/fr/documentation/templates/reference/",
  "feed_url": "https://cloudflare.cecil.app/fr/documentation/templates/reference/feed.json",
  "description": "Référence des fonctions, tris et filtres Twig fournis par Cecil.",
  "icon": "https://cloudflare.cecil.app/favicon.7ff4b89eec6dad139a7d2d6561543285.png",
  "favicon": "https://cloudflare.cecil.app/thumbnails/64x/favicon.7ff4b89eec6dad139a7d2d6561543285.png",
  "language": "fr",
  "items": [
    {
      "id": "https://cloudflare.cecil.app/fr/documentation/templates/reference/fonctions/",
      "url": "https://cloudflare.cecil.app/fr/documentation/templates/reference/fonctions/",
      "title": "Fonctions",
      "summary": "url, html, readtime, hash, cache_key, getenv, dump, tests, etc.",
      "date_published": "2026-05-26T00:00:00+00:00",
      "date_modified": "2026-10-22T00:00:00+00:00","content_text": "Fonctions\n\nLes fonctions peuvent être appelées pour générer du contenu. Les fonctions sont appelées par leur nom suivi de parenthèses (()) et peuvent avoir des arguments.\n\nVoir aussi : les fonctions dédiées aux assets (asset, integrity, image_srcset, image_sizes, image_from_website, etc.) sont documentées dans la section Assets.\nurl\nCrée une URL valide pour une page, une entrée de menu, un asset, un ID de page ou un chemin.\n{{ url(value, {options}) }}\n\n\n\nOption\nDescription\nType\nPar défaut\n\n\n\n\ncanonical\nPréfixe l’URL avec baseurl ou utilise canonical.url s’il existe.\nbooléen\nvaleur de canonicalurl (false par défaut)\n\n\nformat\nDéfinit le format de sortie de la page (ex. : json).\nchaîne\nhtml\n\n\nlanguage\nDéfinit la langue de la page (ex. : fr).\nchaîne\nlangue actuelle\n\n\n\nExemples :\n{# page #}\n{{ url(page) }}\n{{ url(page, {canonical: true}) }}\n{{ url(page, {format: 'json'}) }}\n{{ url(page, {language: 'fr'}) }}\n{# menu entry #}\n{{ url(site.menus.main.about) }}\n{# asset #}\n{{ url(asset('styles.css')) }}\n{# page ID #}\n{{ url('page-id') }}\n{# path #}\n{{ url('about-me\/') }}\n{{ url('tags\/' ~ tag) }}\nPour plus de commodité, la fonction url est également disponible sous forme de filtre :\n{# page #}\n{{ page|url }}\n{{ page|url({canonical: true, format: 'json', language: 'fr'}) }}\n{# asset #}\n{{ asset('styles.css')|url }}\nLorsque la valeur est une chaîne, url() la « slugifie » pour trouver un ID de page correspondant (ex. : url('tags\/My Tag') retourne l’URL de la page tags\/my-tag). Si aucune page ne correspond, la chaîne est conservée comme chemin, avec les caractères invalides (ex. : espaces) encodés.\nhtml\nCrée un élément HTML à partir d’un asset (ou d’un tableau d’assets avec des attributs personnalisés).\n{{ html(asset, {attributes}, {options}) }}\n{# dedicated functions for each common type of asset #}\n{{ css(asset) }}\n{{ js(asset) }}\n{{ image(asset) }}\n{{ audio(asset) }}\n{{ video(asset) }}\n\n\n\nArgument\nDescription\nType\n\n\n\n\nattributes\nAjoute le couple name=\"value\" à l’élément HTML.\ntableau\n\n\noptions\n{preload: boolean} : précharge.Pour les images :{formats: array} : ajoute des formats alternatifs.{responsive: bool|string} : ajoute des images responsives (basées sur la largeur, width, ou la densité de pixels, density).{placeholder: string} : remplit l’arrière-plan de l’image avant son chargement (color ou lqip).\ntableau\n\n\n\nDepuis la version 8.42.0, la fonction html remplace le filtre html obsolète.\nVous pouvez définir un comportement global par défaut des options d’images (formats, responsive et placeholder) via la configuration des layouts.\nLorsque layouts.images.dark_suffix est configuré (par exemple .dark), Cecil recherche automatiquement une variante sombre de chaque image (par exemple photo.dark.jpg aux côtés de photo.jpg) et génère un élément &lt;picture&gt; avec un &lt;source media=\"(prefers-color-scheme: dark)\"&gt;.\nDe la même manière, lorsque layouts.images.mobile_suffix est configuré (par exemple .mobile), Cecil recherche une variante mobile de chaque image (par exemple photo.mobile.jpg) et ajoute un &lt;source&gt; avec la media query layouts.images.mobile_media_query. Si une variante sombre de l’image mobile existe (par exemple photo.mobile.dark.jpg), elle est utilisée sur mobile en mode sombre.\nExemples :\n{# CSS with an attribute #}\n{{ html(asset('print.css'), {media: 'print'}) }}\n{# CSS with an attribute and an option #}\n{{ html(asset('styles.css'), {title: 'Main theme'}, {preload: true}) }}\n{# Array of assets with media query #}\n{{ html([\n  {asset: asset('css\/style.css')},\n  {asset: asset('css\/style-dark.css'), attributes: {media: '(prefers-color-scheme: dark)'}}\n]) }}\n{# JavaScript #}\n{{ html(asset('script.js')) }}\n{# image without specific attributes nor options #}\n{{ html(asset('image.png')) }}\n{# image with specific attributes, responsive images and alternative formats #}\n{{ html(asset('image.jpg'), {alt: 'Description', loading: 'lazy'}, {responsive: true, formats: ['avif', 'webp']}) }}\n{# image with responsive pixels density images #}\n{{ html(asset('image.jpg'), options={responsive: 'density'}, attributes={width: 256}) }}\n{# image with a Low-Quality Image Placeholder #}\n{{ html(asset('image.jpg'), {alt: 'Description', loading: 'lazy'}, {placeholder: 'lqip'}) }}\n{# Audio #}\n{{ html(asset('audio.mp3')) }}\n{# Video #}\n{{ html(asset('video.mp4')) }}\nPour plus de commodité, la fonction html reste disponible en tant que filtre (obsolète) :\n{{ asset|html({attributes}, {options}) }}\nreadtime\nDétermine le temps de lecture d’un texte, en minutes (sur la base de 200 mots par minute, 1 minute minimum).\n{{ readtime(value) }}\nExemple :\n{{ readtime(page.content) }} min\nhash\nCalcule le hachage d’un objet, d’un tableau ou d’une chaîne avec un algorithme donné.\n{{ hash(value, algorithm) }}\nalgorithm peut être n’importe quel algorithme pris en charge par la fonction hash() de PHP (ex. : md5, sha256, etc.). La valeur par défaut est xxh128.\nExemple :\n{{ hash('my string', 'sha256') }}\ncache_key\nCalcule une clé pour le cache de fragments en fonction d’un nom et d’une valeur facultative.\n{% cache cache_key(name, value) %}\n  {# cacheable content #}\n{% endcache %}\nLa fonction ajoute au nom un hachage de la valeur (qui peut être une chaîne, un tableau ou un objet), ainsi que la langue actuelle et l’ID de génération, pour garantir que la clé de cache générée est unique : si la valeur change, la clé de cache change aussi et une nouvelle entrée de cache est générée.\ngetenv\nObtient la valeur d’une variable d’environnement à partir de sa clé.\n{{ getenv(var) }}\nExemple :\n{{ getenv('VAR') }}\ndump\nLa fonction dump affiche les informations sur une variable de template. C’est surtout utile pour déboguer un template qui ne se comporte pas comme prévu, en inspectant ses variables :\n{{ dump(user) }}\nLe mode debug doit être activé.\nd\nLa fonction d() est la version HTML de dump() et utilise le composant Symfony VarDumper en arrière-plan.\n{{ d(variable, {theme: 'dark'}) }}\n\nSi variable n’est pas fournie, la fonction affiche le contexte Twig actuel\nLes thèmes disponibles sont light (par défaut) et dark\n\nLe mode debug doit être activé.\nTests\nLes tests s’utilisent avec l’opérateur is.\n\n\n\nTest\nDescription\n\n\n\n\nasset\nLa variable est un asset.\n\n\nimage_large\nL’asset est une image au format paysage d’au moins 600 × 315 pixels (ex. : une image de couverture).\n\n\nimage_square\nL’asset est une image carrée (largeur et hauteur identiques).\n\n\nenabled\nL’option est activée : true, un tableau associatif sans clé enabled ou avec enabled: true, ou toute autre valeur sauf false et null.\n\n\nexternal\nL’URL (ou l’URL d’une entrée de menu) est externe : elle a un schéma (https:, mailto:, etc.) ou commence par \/\/, et ne commence pas par baseurl.\n\n\n\nExemple :\n{% set image = asset(page.image) %}\n{% if image is image_large %}\n  {{ html(image, {alt: page.title}) }}\n{% endif %}\n{% if config.cache is enabled %}\n  {# `cache: false` et `cache: {enabled: false}` sont tous deux désactivés #}\n{% endif %}\n{% for item in site.menus.main|sort_by_weight %}\n  &lt;a href=\"{{ url(item.url) }}\"{% if item is external %} rel=\"noopener\" target=\"_blank\"{% endif %}&gt;{{ item.name }}&lt;\/a&gt;\n{% endfor %}\nLe test enabled ne vérifie que la valeur donnée, pas ses parents : config.optimize.html is enabled peut être vrai alors que optimize est désactivé.\nUne option personnalisée peut ne pas exister : utilisez le filtre default (ex. config.myoption|default(false) is enabled).\nObsolètes\nLes fonctions suivantes sont obsolètes (un avertissement de dépréciation est émis lorsqu’elles sont utilisées) :\n\n\n\nFonction\nRemplacement\n\n\n\n\nminify()\nfiltre minify\n\n\ntoCSS()\nfiltre to_css\n\n\nimage_from_url()\nfonction image_from_website()\n\n\n",
      "content_html": "<h1>Fonctions</h1>\n<blockquote>\n<p>Les <a href=\"https://twig.symfony.com/doc/functions/index.html\" target=\"_blank\" rel=\"noopener noreferrer\">fonctions</a> peuvent être appelées pour générer du contenu. Les fonctions sont appelées par leur nom suivi de parenthèses (<code translate=\"no\">()</code>) et peuvent avoir des arguments.</p>\n</blockquote>\n<aside class=\"note note-info\"><p>Voir aussi : les fonctions dédiées aux assets (<code translate=\"no\">asset</code>, <code translate=\"no\">integrity</code>, <code translate=\"no\">image_srcset</code>, <code translate=\"no\">image_sizes</code>, <code translate=\"no\">image_from_website</code>, etc.) sont documentées dans la section <a href=\"../../assets/index.fr.md\">Assets</a>.</p></aside>\n<h2 id=\"url\">url<a class=\"heading-anchor\" href=\"#url\" aria-hidden=\"true\" tabindex=\"-1\"></a></h2>\n<p>Crée une URL valide pour une page, une entrée de menu, un asset, un ID de page ou un chemin.</p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-variable\">{{ url(value, {options}) }}</span></code></pre>\n<table>\n<thead>\n<tr>\n<th>Option</th>\n<th>Description</th>\n<th>Type</th>\n<th>Par défaut</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>canonical</td>\n<td>Préfixe l’URL avec <a href=\"../../configuration/1-site.fr.md#baseurl\"><code translate=\"no\">baseurl</code></a> ou utilise <a href=\"../../configuration/1-site.fr.md#options-metatags\"><code translate=\"no\">canonical.url</code></a> s’il existe.</td>\n<td>booléen</td>\n<td>valeur de <a href=\"../../configuration/1-site.fr.md#canonicalurl\"><code translate=\"no\">canonicalurl</code></a> (<code translate=\"no\">false</code> par défaut)</td>\n</tr>\n<tr>\n<td>format</td>\n<td>Définit le <a href=\"../../configuration/8-output.fr.md#output-formats\">format de sortie</a> de la page (ex. : <code translate=\"no\">json</code>).</td>\n<td>chaîne</td>\n<td><code translate=\"no\">html</code></td>\n</tr>\n<tr>\n<td>language</td>\n<td>Définit la <a href=\"../../configuration/2-languages.fr.md#language\">langue</a> de la page (ex. : <code translate=\"no\">fr</code>).</td>\n<td>chaîne</td>\n<td>langue actuelle</td>\n</tr>\n</tbody>\n</table>\n<p><em>Exemples :</em></p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-comment\">{# page #}</span><span class=\"xml\">\n</span><span class=\"hljs-template-variable\">{{ url(page) }}</span><span class=\"xml\">\n</span><span class=\"hljs-template-variable\">{{ url(page, {canonical: true}) }}</span><span class=\"xml\">\n</span><span class=\"hljs-template-variable\">{{ url(page, {format: 'json'}) }}</span><span class=\"xml\">\n</span><span class=\"hljs-template-variable\">{{ url(page, {language: 'fr'}) }}</span><span class=\"xml\">\n</span><span class=\"hljs-comment\">{# menu entry #}</span><span class=\"xml\">\n</span><span class=\"hljs-template-variable\">{{ url(site.menus.main.about) }}</span><span class=\"xml\">\n</span><span class=\"hljs-comment\">{# asset #}</span><span class=\"xml\">\n</span><span class=\"hljs-template-variable\">{{ url(asset('styles.css')) }}</span><span class=\"xml\">\n</span><span class=\"hljs-comment\">{# page ID #}</span><span class=\"xml\">\n</span><span class=\"hljs-template-variable\">{{ url('page-id') }}</span><span class=\"xml\">\n</span><span class=\"hljs-comment\">{# path #}</span><span class=\"xml\">\n</span><span class=\"hljs-template-variable\">{{ url('about-me/') }}</span><span class=\"xml\">\n</span><span class=\"hljs-template-variable\">{{ url('tags/' ~ tag) }}</span></code></pre>\n<aside class=\"note note-info\"><p>Pour plus de commodité, la fonction <code translate=\"no\">url</code> est également disponible sous forme de filtre :</p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-comment\">{# page #}</span><span class=\"xml\">\n</span><span class=\"hljs-template-variable\">{{ page|url }}</span><span class=\"xml\">\n</span><span class=\"hljs-template-variable\">{{ page|url({canonical: true, format: 'json', language: 'fr'}) }}</span><span class=\"xml\">\n</span><span class=\"hljs-comment\">{# asset #}</span><span class=\"xml\">\n</span><span class=\"hljs-template-variable\">{{ asset('styles.css')|url }}</span></code></pre></aside>\n<aside class=\"note note-tip\"><p>Lorsque la valeur est une chaîne, <code translate=\"no\">url()</code> la « slugifie » pour trouver un ID de page correspondant (ex. : <code translate=\"no\">url('tags/My Tag')</code> retourne l’URL de la page <code translate=\"no\">tags/my-tag</code>). Si aucune page ne correspond, la chaîne est conservée comme chemin, avec les caractères invalides (ex. : espaces) encodés.</p></aside>\n<h2 id=\"html\">html<a class=\"heading-anchor\" href=\"#html\" aria-hidden=\"true\" tabindex=\"-1\"></a></h2>\n<p>Crée un élément HTML à partir d’un asset (ou d’un tableau d’assets avec des attributs personnalisés).</p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-variable\">{{ html(asset, {attributes}, {options}) }}</span><span class=\"xml\">\n</span><span class=\"hljs-comment\">{# dedicated functions for each common type of asset #}</span><span class=\"xml\">\n</span><span class=\"hljs-template-variable\">{{ css(asset) }}</span><span class=\"xml\">\n</span><span class=\"hljs-template-variable\">{{ js(asset) }}</span><span class=\"xml\">\n</span><span class=\"hljs-template-variable\">{{ image(asset) }}</span><span class=\"xml\">\n</span><span class=\"hljs-template-variable\">{{ audio(asset) }}</span><span class=\"xml\">\n</span><span class=\"hljs-template-variable\">{{ video(asset) }}</span></code></pre>\n<table>\n<thead>\n<tr>\n<th>Argument</th>\n<th>Description</th>\n<th>Type</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>attributes</td>\n<td>Ajoute le couple <code translate=\"no\">name=\"value\"</code> à l’élément HTML.</td>\n<td>tableau</td>\n</tr>\n<tr>\n<td>options</td>\n<td><code translate=\"no\">{preload: boolean}</code> : précharge.<br>Pour les images :<br><code translate=\"no\">{formats: array}</code> : ajoute des formats alternatifs.<br><code translate=\"no\">{responsive: bool|string}</code> : ajoute des images responsives (basées sur la largeur, <code translate=\"no\">width</code>, ou la densité de pixels, <code translate=\"no\">density</code>).<br><code translate=\"no\">{placeholder: string}</code> : remplit l’arrière-plan de l’image avant son chargement (<code translate=\"no\">color</code> ou <code translate=\"no\">lqip</code>).</td>\n<td>tableau</td>\n</tr>\n</tbody>\n</table>\n<aside class=\"note note-warning\"><p>Depuis la version <ins>8.42.0</ins>, la fonction <code translate=\"no\">html</code> remplace le filtre <code translate=\"no\">html</code> obsolète.</p></aside>\n<aside class=\"note note-tip\"><p>Vous pouvez définir un comportement global par défaut des options d’images (<code translate=\"no\">formats</code>, <code translate=\"no\">responsive</code> et <code translate=\"no\">placeholder</code>) via la <a href=\"../../configuration/7-layouts.fr.md#layouts-images\">configuration des layouts</a>.</p>\n<p>Lorsque <a href=\"../../configuration/7-layouts.fr.md#layouts-images\"><code translate=\"no\">layouts.images.dark_suffix</code></a> est configuré (par exemple <code translate=\"no\">.dark</code>), Cecil recherche automatiquement une variante sombre de chaque image (par exemple <code translate=\"no\">photo.dark.jpg</code> aux côtés de <code translate=\"no\">photo.jpg</code>) et génère un élément <code translate=\"no\">&lt;picture&gt;</code> avec un <code translate=\"no\">&lt;source media=\"(prefers-color-scheme: dark)\"&gt;</code>.</p>\n<p>De la même manière, lorsque <a href=\"../../configuration/7-layouts.fr.md#layouts-images\"><code translate=\"no\">layouts.images.mobile_suffix</code></a> est configuré (par exemple <code translate=\"no\">.mobile</code>), Cecil recherche une variante mobile de chaque image (par exemple <code translate=\"no\">photo.mobile.jpg</code>) et ajoute un <code translate=\"no\">&lt;source&gt;</code> avec la media query <a href=\"../../configuration/7-layouts.fr.md#layouts-images\"><code translate=\"no\">layouts.images.mobile_media_query</code></a>. Si une variante sombre de l’image mobile existe (par exemple <code translate=\"no\">photo.mobile.dark.jpg</code>), elle est utilisée sur mobile en mode sombre.</p></aside>\n<p><em>Exemples :</em></p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-comment\">{# CSS with an attribute #}</span><span class=\"xml\">\n</span><span class=\"hljs-template-variable\">{{ html(asset('print.css'), {media: 'print'}) }}</span><span class=\"xml\">\n</span><span class=\"hljs-comment\">{# CSS with an attribute and an option #}</span><span class=\"xml\">\n</span><span class=\"hljs-template-variable\">{{ html(asset('styles.css'), {title: 'Main theme'}, {preload: true}) }}</span><span class=\"xml\">\n</span><span class=\"hljs-comment\">{# Array of assets with media query #}</span><span class=\"xml\">\n</span><span class=\"hljs-template-variable\">{{ html([\n  {asset: asset('css/style.css')},\n  {asset: asset('css/style-dark.css'), attributes: {media: '(prefers-color-scheme: dark)'}}</span><span class=\"xml\">\n]) }}\n</span><span class=\"hljs-comment\">{# JavaScript #}</span><span class=\"xml\">\n</span><span class=\"hljs-template-variable\">{{ html(asset('script.js')) }}</span><span class=\"xml\">\n</span><span class=\"hljs-comment\">{# image without specific attributes nor options #}</span><span class=\"xml\">\n</span><span class=\"hljs-template-variable\">{{ html(asset('image.png')) }}</span><span class=\"xml\">\n</span><span class=\"hljs-comment\">{# image with specific attributes, responsive images and alternative formats #}</span><span class=\"xml\">\n</span><span class=\"hljs-template-variable\">{{ html(asset('image.jpg'), {alt: 'Description', loading: 'lazy'}, {responsive: true, formats: ['avif', 'webp']}) }}</span><span class=\"xml\">\n</span><span class=\"hljs-comment\">{# image with responsive pixels density images #}</span><span class=\"xml\">\n</span><span class=\"hljs-template-variable\">{{ html(asset('image.jpg'), options={responsive: 'density'}, attributes={width: 256}) }}</span><span class=\"xml\">\n</span><span class=\"hljs-comment\">{# image with a Low-Quality Image Placeholder #}</span><span class=\"xml\">\n</span><span class=\"hljs-template-variable\">{{ html(asset('image.jpg'), {alt: 'Description', loading: 'lazy'}, {placeholder: 'lqip'}) }}</span><span class=\"xml\">\n</span><span class=\"hljs-comment\">{# Audio #}</span><span class=\"xml\">\n</span><span class=\"hljs-template-variable\">{{ html(asset('audio.mp3')) }}</span><span class=\"xml\">\n</span><span class=\"hljs-comment\">{# Video #}</span><span class=\"xml\">\n</span><span class=\"hljs-template-variable\">{{ html(asset('video.mp4')) }}</span></code></pre>\n<aside class=\"note note-info\"><p>Pour plus de commodité, la fonction <code translate=\"no\">html</code> reste disponible en tant que filtre (obsolète) :</p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-variable\">{{ asset|html({attributes}, {options}) }}</span></code></pre></aside>\n<h2 id=\"readtime\">readtime<a class=\"heading-anchor\" href=\"#readtime\" aria-hidden=\"true\" tabindex=\"-1\"></a></h2>\n<p>Détermine le temps de lecture d’un texte, en minutes (sur la base de 200 mots par minute, 1 minute minimum).</p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-variable\">{{ readtime(value) }}</span></code></pre>\n<p><em>Exemple :</em></p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-variable\">{{ readtime(page.content) }}</span><span class=\"xml\"> min</span></code></pre>\n<h2 id=\"hash\">hash<a class=\"heading-anchor\" href=\"#hash\" aria-hidden=\"true\" tabindex=\"-1\"></a></h2>\n<p>Calcule le hachage d’un objet, d’un tableau ou d’une chaîne avec un algorithme donné.</p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-variable\">{{ hash(value, algorithm) }}</span></code></pre>\n<p><code translate=\"no\">algorithm</code> peut être n’importe quel algorithme pris en charge par la fonction <code translate=\"no\">hash()</code> de PHP (ex. : <code translate=\"no\">md5</code>, <code translate=\"no\">sha256</code>, etc.). La valeur par défaut est <code translate=\"no\">xxh128</code>.</p>\n<p><em>Exemple :</em></p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-variable\">{{ hash('my string', 'sha256') }}</span></code></pre>\n<h2 id=\"cache-key\">cache_key<a class=\"heading-anchor\" href=\"#cache-key\" aria-hidden=\"true\" tabindex=\"-1\"></a></h2>\n<p>Calcule une clé pour le <a href=\"../6-cache.fr.md#cache-de-fragments\">cache de <em>fragments</em></a> en fonction d’un nom et d’une valeur facultative.</p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-tag\">{% <span class=\"hljs-name\">cache</span> cache_key(name, value) %}</span><span class=\"xml\">\n  </span><span class=\"hljs-comment\">{# cacheable content #}</span><span class=\"xml\">\n</span><span class=\"hljs-template-tag\">{% <span class=\"hljs-name\">endcache</span> %}</span></code></pre>\n<p>La fonction ajoute au nom un hachage de la valeur (qui peut être une chaîne, un tableau ou un objet), ainsi que la langue actuelle et l’ID de génération, pour garantir que la clé de cache générée est unique : si la valeur change, la clé de cache change aussi et une nouvelle entrée de cache est générée.</p>\n<h2 id=\"getenv\">getenv<a class=\"heading-anchor\" href=\"#getenv\" aria-hidden=\"true\" tabindex=\"-1\"></a></h2>\n<p>Obtient la valeur d’une variable d’environnement à partir de sa clé.</p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-variable\">{{ getenv(var) }}</span></code></pre>\n<p><em>Exemple :</em></p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-variable\">{{ getenv('VAR') }}</span></code></pre>\n<h2 id=\"dump\">dump<a class=\"heading-anchor\" href=\"#dump\" aria-hidden=\"true\" tabindex=\"-1\"></a></h2>\n<p>La fonction <code translate=\"no\">dump</code> affiche les informations sur une variable de template. C’est surtout utile pour déboguer un template qui ne se comporte pas comme prévu, en inspectant ses variables :</p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-variable\">{{ <span class=\"hljs-name\">dump</span><span class=\"hljs-params\">(user)</span> }}</span></code></pre>\n<aside class=\"note note-important\"><p>Le <a href=\"../../configuration/1-site.fr.md#debug\"><em>mode debug</em></a> doit être activé.</p></aside>\n<h2 id=\"d\">d<a class=\"heading-anchor\" href=\"#d\" aria-hidden=\"true\" tabindex=\"-1\"></a></h2>\n<p>La fonction <code translate=\"no\">d()</code> est la version HTML de <a href=\"#dump\"><code translate=\"no\">dump()</code></a> et utilise le <a href=\"https://symfony.com/doc/current/components/var_dumper.html\" target=\"_blank\" rel=\"noopener noreferrer\">composant Symfony VarDumper</a> en arrière-plan.</p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-variable\">{{ d(variable, {theme: 'dark'}) }}</span></code></pre>\n<ul>\n<li>Si <em>variable</em> n’est pas fournie, la fonction affiche le contexte Twig actuel</li>\n<li>Les thèmes disponibles sont <code translate=\"no\">light</code> (par défaut) et <code translate=\"no\">dark</code></li>\n</ul>\n<aside class=\"note note-important\"><p>Le <a href=\"../../configuration/1-site.fr.md#debug\"><em>mode debug</em></a> doit être activé.</p></aside>\n<h2 id=\"tests\">Tests<a class=\"heading-anchor\" href=\"#tests\" aria-hidden=\"true\" tabindex=\"-1\"></a></h2>\n<p>Les <a href=\"https://twig.symfony.com/doc/tests/index.html\" target=\"_blank\" rel=\"noopener noreferrer\">tests</a> s’utilisent avec l’opérateur <code translate=\"no\">is</code>.</p>\n<table>\n<thead>\n<tr>\n<th>Test</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code translate=\"no\">asset</code></td>\n<td>La variable est un <a href=\"../../assets/index.fr.md#asset\">asset</a>.</td>\n</tr>\n<tr>\n<td><code translate=\"no\">image_large</code></td>\n<td>L’asset est une image au format paysage d’au moins 600 × 315 pixels (ex. : une image de couverture).</td>\n</tr>\n<tr>\n<td><code translate=\"no\">image_square</code></td>\n<td>L’asset est une image carrée (largeur et hauteur identiques).</td>\n</tr>\n<tr>\n<td><code translate=\"no\">enabled</code></td>\n<td>L’option est activée : <code translate=\"no\">true</code>, un tableau associatif sans clé <code translate=\"no\">enabled</code> ou avec <code translate=\"no\">enabled: true</code>, ou toute autre valeur sauf <code translate=\"no\">false</code> et <code translate=\"no\">null</code>.</td>\n</tr>\n<tr>\n<td><code translate=\"no\">external</code></td>\n<td>L’URL (ou l’URL d’une entrée de menu) est externe : elle a un schéma (<code translate=\"no\">https:</code>, <code translate=\"no\">mailto:</code>, etc.) ou commence par <code translate=\"no\">//</code>, et ne commence pas par <code translate=\"no\">baseurl</code>.</td>\n</tr>\n</tbody>\n</table>\n<p><em>Exemple :</em></p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-tag\">{% <span class=\"hljs-name\"><span class=\"hljs-keyword\">set</span></span> image = asset(page.image) %}</span><span class=\"xml\">\n</span><span class=\"hljs-template-tag\">{% <span class=\"hljs-name\"><span class=\"hljs-keyword\">if</span></span> image is image_large %}</span><span class=\"xml\">\n  </span><span class=\"hljs-template-variable\">{{ html(image, {alt: page.title}) }}</span><span class=\"xml\">\n</span><span class=\"hljs-template-tag\">{% <span class=\"hljs-name\"><span class=\"hljs-keyword\">endif</span></span> %}</span></code></pre>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-tag\">{% <span class=\"hljs-name\"><span class=\"hljs-keyword\">if</span></span> config.cache is enabled %}</span><span class=\"xml\">\n  </span><span class=\"hljs-comment\">{# `cache: false` et `cache: {enabled: false}` sont tous deux désactivés #}</span><span class=\"xml\">\n</span><span class=\"hljs-template-tag\">{% <span class=\"hljs-name\"><span class=\"hljs-keyword\">endif</span></span> %}</span></code></pre>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-tag\">{% <span class=\"hljs-name\"><span class=\"hljs-keyword\">for</span></span> item in site.menus.main|sort_by_weight %}</span><span class=\"xml\">\n  <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">a</span> <span class=\"hljs-attr\">href</span>=<span class=\"hljs-string\">\"</span></span></span><span class=\"hljs-template-variable\">{{ url(item.url) }}</span><span class=\"xml\"><span class=\"hljs-tag\"><span class=\"hljs-string\">\"</span></span></span><span class=\"hljs-template-tag\">{% <span class=\"hljs-name\"><span class=\"hljs-keyword\">if</span></span> item is external %}</span><span class=\"xml\"><span class=\"hljs-tag\"> <span class=\"hljs-attr\">rel</span>=<span class=\"hljs-string\">\"noopener\"</span> <span class=\"hljs-attr\">target</span>=<span class=\"hljs-string\">\"_blank\"</span></span></span><span class=\"hljs-template-tag\">{% <span class=\"hljs-name\"><span class=\"hljs-keyword\">endif</span></span> %}</span><span class=\"xml\"><span class=\"hljs-tag\">&gt;</span></span><span class=\"hljs-template-variable\">{{ item.name }}</span><span class=\"xml\"><span class=\"hljs-tag\">&lt;/<span class=\"hljs-name\">a</span>&gt;</span>\n</span><span class=\"hljs-template-tag\">{% <span class=\"hljs-name\"><span class=\"hljs-keyword\">endfor</span></span> %}</span></code></pre>\n<aside class=\"note note-info\"><p>Le test <code translate=\"no\">enabled</code> ne vérifie que la valeur donnée, pas ses parents : <code translate=\"no\">config.optimize.html is enabled</code> peut être vrai alors que <code translate=\"no\">optimize</code> est désactivé.\nUne option personnalisée peut ne pas exister : utilisez le filtre <code translate=\"no\">default</code> (ex. <code translate=\"no\">config.myoption|default(false) is enabled</code>).</p></aside>\n<h2 id=\"obsoletes\">Obsolètes<a class=\"heading-anchor\" href=\"#obsoletes\" aria-hidden=\"true\" tabindex=\"-1\"></a></h2>\n<p>Les fonctions suivantes sont obsolètes (un avertissement de dépréciation est émis lorsqu’elles sont utilisées) :</p>\n<table>\n<thead>\n<tr>\n<th>Fonction</th>\n<th>Remplacement</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code translate=\"no\">minify()</code></td>\n<td>filtre <a href=\"../../assets/2-processing.fr.md#minify\"><code translate=\"no\">minify</code></a></td>\n</tr>\n<tr>\n<td><code translate=\"no\">toCSS()</code></td>\n<td>filtre <a href=\"../../assets/2-processing.fr.md#to-css\"><code translate=\"no\">to_css</code></a></td>\n</tr>\n<tr>\n<td><code translate=\"no\">image_from_url()</code></td>\n<td>fonction <a href=\"../../assets/1-images.fr.md#image-from-website\"><code translate=\"no\">image_from_website()</code></a></td>\n</tr>\n</tbody>\n</table>",
      "language": "fr"
    },
    {
      "id": "https://cloudflare.cecil.app/fr/documentation/templates/reference/tris/",
      "url": "https://cloudflare.cecil.app/fr/documentation/templates/reference/tris/",
      "title": "Tris",
      "summary": "Triez des collections de pages, menus ou taxonomies.",
      "date_published": "2026-05-26T00:00:00+00:00",
      "date_modified": "2026-10-16T00:00:00+00:00","content_text": "Tris\nTri des collections (de pages, menus ou taxonomies).\nsort_by_title\nTrie une collection par titre (avec un tri naturel).\n{{ collection|sort_by_title }}\nExemple :\n{{ site.pages|sort_by_title }}\nsort_by_date\nTrie une collection par date (la plus récente en premier).\n{{ collection|sort_by_date(variable='date', desc_title=false) }}\n\nvariable : la variable de date utilisée pour le tri (date par défaut)\ndesc_title : trie les éléments ayant la même date par titre, dans l’ordre décroissant (false par défaut)\n\nExemple :\n{# sort by date #}\n{{ site.pages|sort_by_date }}\n{# sort by updated variable instead of date #}\n{{ site.pages|sort_by_date(variable='updated') }}\n{# sort items with the same date by desc title #}\n{{ site.pages|sort_by_date(desc_title=true) }}\n{# reverse sort #}\n{{ site.pages|sort_by_date|reverse }}\nsort_by_weight\nTrie une collection par poids (le plus léger en premier).\n{{ collection|sort_by_weight }}\nExemple :\n{{ site.menus.main|sort_by_weight }}\nsort\nPour les cas plus complexes, il est préférable d’utiliser le filtre natif sort de Twig.\nExemple :\n{% set files = site.static|sort((a, b) =&gt; b.date &lt;=&gt; a.date) %}\nMéthodes de collection\nUne collection de pages (ex. : site.pages, page.pages) fournit également des méthodes de tri, qui renvoient une collection de pages :\n\nsortBy(options) : trie par date, updated, title ou weight\nsortByDate(options), sortByTitle(options), sortByWeight(options)\n\noptions peut être le nom de la variable (ex. : 'title') ou un objet avec les clés variable, descTitle (tri par date uniquement) et reverse.\nExemples :\n{% for p in site.pages.showable.sortBy('title') %}…{% endfor %}\n{% for p in site.pages.showable.sortBy({variable: 'updated', reverse: true}) %}…{% endfor %}",
      "content_html": "<h1>Tris</h1>\n<p>Tri des collections (de pages, menus ou taxonomies).</p>\n<h2 id=\"sort-by-title\">sort_by_title<a class=\"heading-anchor\" href=\"#sort-by-title\" aria-hidden=\"true\" tabindex=\"-1\"></a></h2>\n<p>Trie une collection par titre (avec un <a href=\"https://en.wikipedia.org/wiki/Natural_sort_order\" target=\"_blank\" rel=\"noopener noreferrer\">tri naturel</a>).</p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-variable\">{{ collection|sort_by_title }}</span></code></pre>\n<p><em>Exemple :</em></p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-variable\">{{ site.pages|sort_by_title }}</span></code></pre>\n<h2 id=\"sort-by-date\">sort_by_date<a class=\"heading-anchor\" href=\"#sort-by-date\" aria-hidden=\"true\" tabindex=\"-1\"></a></h2>\n<p>Trie une collection par date (la plus récente en premier).</p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-variable\">{{ collection|sort_by_date(variable='<span class=\"hljs-name\">date</span>', desc_title=false) }}</span></code></pre>\n<ul>\n<li><code translate=\"no\">variable</code> : la variable de date utilisée pour le tri (<code translate=\"no\">date</code> par défaut)</li>\n<li><code translate=\"no\">desc_title</code> : trie les éléments ayant la même date par titre, dans l’ordre décroissant (<code translate=\"no\">false</code> par défaut)</li>\n</ul>\n<p><em>Exemple :</em></p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-comment\">{# sort by date #}</span><span class=\"xml\">\n</span><span class=\"hljs-template-variable\">{{ site.pages|sort_by_date }}</span><span class=\"xml\">\n</span><span class=\"hljs-comment\">{# sort by updated variable instead of date #}</span><span class=\"xml\">\n</span><span class=\"hljs-template-variable\">{{ site.pages|sort_by_date(variable='updated') }}</span><span class=\"xml\">\n</span><span class=\"hljs-comment\">{# sort items with the same date by desc title #}</span><span class=\"xml\">\n</span><span class=\"hljs-template-variable\">{{ site.pages|sort_by_date(desc_title=true) }}</span><span class=\"xml\">\n</span><span class=\"hljs-comment\">{# reverse sort #}</span><span class=\"xml\">\n</span><span class=\"hljs-template-variable\">{{ site.pages|sort_by_date|<span class=\"hljs-keyword\">reverse</span> }}</span></code></pre>\n<h2 id=\"sort-by-weight\">sort_by_weight<a class=\"heading-anchor\" href=\"#sort-by-weight\" aria-hidden=\"true\" tabindex=\"-1\"></a></h2>\n<p>Trie une collection par poids (le plus léger en premier).</p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-variable\">{{ collection|sort_by_weight }}</span></code></pre>\n<p><em>Exemple :</em></p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-variable\">{{ site.menus.main|sort_by_weight }}</span></code></pre>\n<h2 id=\"sort\">sort<a class=\"heading-anchor\" href=\"#sort\" aria-hidden=\"true\" tabindex=\"-1\"></a></h2>\n<p>Pour les cas plus complexes, il est préférable d’utiliser le filtre natif <a href=\"https://twig.symfony.com/doc/filters/sort.html\" target=\"_blank\" rel=\"noopener noreferrer\"><code translate=\"no\">sort</code></a> de Twig.</p>\n<p><em>Exemple :</em></p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-tag\">{% <span class=\"hljs-name\"><span class=\"hljs-keyword\">set</span></span> files = site.static|<span class=\"hljs-keyword\">sort</span>((a, b) =&gt; b.<span class=\"hljs-name\">date</span> &lt;=&gt; a.<span class=\"hljs-name\">date</span>) %}</span></code></pre>\n<h2 id=\"methodes-de-collection\">Méthodes de collection<a class=\"heading-anchor\" href=\"#methodes-de-collection\" aria-hidden=\"true\" tabindex=\"-1\"></a></h2>\n<p>Une collection de pages (ex. : <code translate=\"no\">site.pages</code>, <code translate=\"no\">page.pages</code>) fournit également des méthodes de tri, qui renvoient une collection de pages :</p>\n<ul>\n<li><code translate=\"no\">sortBy(options)</code> : trie par <code translate=\"no\">date</code>, <code translate=\"no\">updated</code>, <code translate=\"no\">title</code> ou <code translate=\"no\">weight</code></li>\n<li><code translate=\"no\">sortByDate(options)</code>, <code translate=\"no\">sortByTitle(options)</code>, <code translate=\"no\">sortByWeight(options)</code></li>\n</ul>\n<p><code translate=\"no\">options</code> peut être le nom de la variable (ex. : <code translate=\"no\">'title'</code>) ou un objet avec les clés <code translate=\"no\">variable</code>, <code translate=\"no\">descTitle</code> (tri par date uniquement) et <code translate=\"no\">reverse</code>.</p>\n<p><em>Exemples :</em></p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-tag\">{% <span class=\"hljs-name\"><span class=\"hljs-keyword\">for</span></span> p in site.pages.showable.sortBy('title') %}</span><span class=\"xml\">…</span><span class=\"hljs-template-tag\">{% <span class=\"hljs-name\"><span class=\"hljs-keyword\">endfor</span></span> %}</span><span class=\"xml\">\n</span><span class=\"hljs-template-tag\">{% <span class=\"hljs-name\"><span class=\"hljs-keyword\">for</span></span> p in site.pages.showable.sortBy({variable: 'updated', reverse: true}) %}</span><span class=\"xml\">…</span><span class=\"hljs-template-tag\">{% <span class=\"hljs-name\"><span class=\"hljs-keyword\">endfor</span></span> %}</span></code></pre>",
      "language": "fr"
    },
    {
      "id": "https://cloudflare.cecil.app/fr/documentation/templates/reference/filtres/",
      "url": "https://cloudflare.cecil.app/fr/documentation/templates/reference/filtres/",
      "title": "Filtres",
      "summary": "filter_by, markdown_to_html, toc, slugify, excerpt, highlight, preg_*, etc.",
      "date_published": "2026-05-26T00:00:00+00:00",
      "date_modified": "2026-11-15T00:00:00+00:00","content_text": "Filtres\nLes variables peuvent être modifiées par des filtres. Les filtres sont séparés de la variable par un symbole de barre verticale (|). Plusieurs filtres peuvent être chaînés. La sortie d’un filtre est appliquée au suivant.\n{{ page.title|truncate(25)|capitalize }}\nVoir aussi : les filtres dédiés aux assets (resize, minify, fingerprint, to_css, inline, webp, lqip, etc.) sont documentés dans la section Assets.\nfilter_by\nFiltre une collection de pages par nom\/valeur de variable.\n{{ collection|filter_by(variable, value) }}\nSeules les pages standards (de type page, hors redirections) sont renvoyées.\nExemple :\n{{ pages|filter_by('section', 'blog') }}\nfilter\nPour les cas plus complexes, il est préférable d’utiliser le filtre natif filter de Twig.\nExemple :\n{% set filtered = pages|filter(p =&gt; p.generated == false and p.id not in ['page-1', 'page-2']) %}\nmarkdown_to_html\nConvertit une chaîne Markdown en HTML.\n{{ markdown|markdown_to_html }}\n{% apply markdown_to_html %}\n{# Markdown here #}\n{% endapply %}\nExemples :\n{% set markdown = '**This is bold text**' %}\n{{ markdown|markdown_to_html }}\n{% apply markdown_to_html %}\n**This is bold text**\n{% endapply %}\ntoc\nExtrait uniquement les titres correspondant aux selectors donnés (h2, h3, etc.), ou à ceux définis dans la configuration pages.body.toc s’ils ne sont pas spécifiés.\nLe paramètre format définit le format de sortie : html (par défaut) ou json.\nLe paramètre url est utilisé pour créer les liens vers les titres.\n{{ markdown|toc(format, selectors, url) }}\nExemples :\n{{ page.body|toc }}\n{{ page.body|toc('html') }}\n{{ page.body|toc(selectors=['h2']) }}\n{{ page.body|toc(url=url(page)) }}\njson_decode\nConvertit une chaîne JSON en tableau.\n{{ json|json_decode }}\nExemple :\n{% set json = '{\"foo\": \"bar\"}' %}\n{% set array = json|json_decode %}\n{{ array.foo }}\nyaml_parse\nConvertit une chaîne YAML en tableau.\n{{ yaml|yaml_parse }}\nExemple :\n{% set yaml = 'key: value' %}\n{% set array = yaml|yaml_parse %}\n{{ array.key }}\nslugify\nConvertit une chaîne en slug.\n{{ string|slugify }}\nu\nLe filtre u enveloppe un texte dans un objet Unicode (une instance Symfony UnicodeString) qui expose des méthodes pour « manipuler » la chaîne.\nExemple :\n{{ 'cecil_string with twig'|u.camel.title }}\n\nCecilStringWithTwig\n\nsingular\nLe filtre singular transforme un nom donné au pluriel en sa version au singulier.\n{{ string|singular(locale) }}\nExemple :\n{# English (en) rules are used by default #}\n{{ 'partitions'|singular }}\n\npartition\n\n{{ 'partitions'|singular('fr') }}\n\npartition\n\nplural\nLe filtre plural transforme un nom donné au singulier en sa version au pluriel.\n{{ string|plural(locale) }}\nExemple :\n{# English (en) rules are used by default #}\n{{ 'animal'|plural }}\n\nanimals\n\n{{ 'animal'|plural('fr') }}\n\nanimaux\n\nexcerpt\nTronque une chaîne et ajoute un suffixe.\n{{ string|excerpt(length, suffix) }}\n\n\n\nOption\nDescription\nType\nPar défaut\n\n\n\n\nlength\nTronque après ce nombre de caractères.\nentier\n450\n\n\nsuffix\nAjoute des caractères.\nchaîne\n' …' (espace et points de suspension)\n\n\n\nExemples :\n{{ variable|excerpt }}\n{{ variable|excerpt(250, '...') }}\nexcerpt_html\nLit les caractères avant ou après la balise &lt;!-- excerpt --&gt; ou &lt;!-- break --&gt;.\nVoir la documentation du contenu pour plus de détails.\n{{ string|excerpt_html({separator, capture}) }}\n\n\n\nOption\nDescription\nType\nPar défaut\n\n\n\n\nseparator\nChaîne à utiliser comme séparateur.\nchaîne\nexcerpt|break\n\n\ncapture\nPartie à capturer, before ou after le séparateur.\nchaîne\nbefore\n\n\n\nLes valeurs par défaut sont définies par la configuration pages.body.excerpt.\nExemples :\n{{ variable|excerpt_html }}\n{{ variable|excerpt_html({separator: 'excerpt|break', capture: 'before'}) }}\n{{ variable|excerpt_html({capture: 'after'}) }}\nabsolute_urls\nRend absolues les URL relatives à la racine (ex. : \/about\/, \/images\/photo.png) des attributs href, src et srcset d'un contenu HTML, avec le schéma et l'hôte de la baseurl, pour utiliser le contenu en dehors du site (flux, e-mails, etc.).\nLes autres URL (URL absolues ou relatives au protocole, chemins relatifs, ancres, mailto:, data:, etc.) sont conservées telles quelles, et le contenu n'est pas modifié si la baseurl n'est pas absolue.\n{{ string|absolute_urls }}\nExemple :\n{# avec `baseurl: https:\/\/example.com\/` #}\n{{ '&lt;a href=\"\/about\/\"&gt;À propos&lt;\/a&gt; &lt;img src=\"\/images\/photo.png\" srcset=\"\/images\/photo-320.png 320w\"&gt;'|absolute_urls }}\n{# &lt;a href=\"https:\/\/example.com\/about\/\"&gt;À propos&lt;\/a&gt; &lt;img src=\"https:\/\/example.com\/images\/photo.png\" srcset=\"https:\/\/example.com\/images\/photo-320.png 320w\"&gt; #}\nLes flux intégrés (Atom, RSS et JSON Feed) appliquent ce filtre au contenu de leurs éléments.\nhighlight\nMet en surbrillance une chaîne de code.\n{{ code|highlight(language, engine) }}\nLe moteur de coloration (highlightjs ou tempest) est l’argument optionnel engine ou, par défaut, l’option layouts.highlight.engine (highlightjs par défaut).\nLe filtre n’utilise pas l’option pages.body.highlight.engine, qui ne s’applique qu’au contenu Markdown.\nSi le langage n’est pas pris en charge par le moteur, le code est retourné échappé, sans coloration (et un avertissement est journalisé).\nExemples :\n{{ '&lt;?php echo $highlighted-&gt;value; ?&gt;'|highlight('php') }}\n{{ '&lt;?php echo $highlighted-&gt;value; ?&gt;'|highlight('php', 'tempest') }}\nChaque moteur utilise ses propres classes CSS (hljs-* pour highlightjs, hl-* pour tempest) : la feuille de style doit correspondre au moteur utilisé.\npreg_split\nDivise une chaîne en un tableau à l’aide d’une expression régulière (limit vaut 0, c’est-à-dire sans limite, par défaut).\n{{ string|preg_split(pattern, limit) }}\nExemple :\n{% set headers = page.content|preg_split('\/&lt;br[^&gt;]*&gt;\/') %}\npreg_match_all\nEffectue une correspondance d’expression régulière et renvoie le groupe pour toutes les correspondances (group vaut 0, c’est-à-dire la correspondance complète, par défaut).\n{{ string|preg_match_all(pattern, group) }}\nExemple :\n{% set tags = page.content|preg_match_all('\/&lt;[^&gt;]+&gt;(.*)&lt;\\\/[^&gt;]+&gt;\/') %}\nhex_to_rgb\nConvertit une couleur hexadécimale en RVB : renvoie un tableau avec les clés red, green et blue.\n{{ color|hex_to_rgb }}\nExemple :\n{% set rgb = '#f00'|hex_to_rgb %}\nrgb({{ rgb.red }}, {{ rgb.green }}, {{ rgb.blue }})\n\nrgb(255, 0, 0)\n\nsplitline\nDivise une chaîne en un tableau de lignes de max caractères maximum (18 par défaut), sans couper les mots.\n{{ string|splitline(max) }}\nExemple :\n{% for line in 'The quick brown fox jumps'|splitline(10) %}\n  {{ line }}&lt;br&gt;\n{% endfor %}\n\nThe quickbrown foxjumps\n\niterable\nConvertit une variable en itérable (tableau) : un tableau est renvoyé tel quel, un objet itérable est converti en tableau, et toute autre valeur est placée dans un tableau.\n{{ variable|iterable }}\nExemple :\n{% for author in page.authors|iterable %}\n  {{ author }}\n{% endfor %}\nunique\nSupprime les valeurs en double d’un tableau de chaînes (sans tenir compte de la casse : la première occurrence est conservée).\n{{ array|unique }}\nExemple :\n{{ ['PHP', 'php', 'Twig']|unique|join(', ') }}\n\nPHP, Twig\n\nduration_to_iso8601\nConvertit une durée en secondes en durée ISO 8601 (ex. : pour la duration d’une vidéo dans les données structurées).\n{{ seconds|duration_to_iso8601 }}\nExemple :\n{{ 125|duration_to_iso8601 }}\n\nPT00H00M125S\n",
      "content_html": "<h1>Filtres</h1>\n<p>Les variables peuvent être modifiées par des <a href=\"https://twig.symfony.com/doc/filters/index.html\" target=\"_blank\" rel=\"noopener noreferrer\">filtres</a>. Les filtres sont séparés de la variable par un symbole de barre verticale (<code translate=\"no\">|</code>). Plusieurs filtres peuvent être chaînés. La sortie d’un filtre est appliquée au suivant.</p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-variable\">{{ page.title|truncate(25)|<span class=\"hljs-keyword\">capitalize</span> }}</span></code></pre>\n<aside class=\"note note-info\"><p>Voir aussi : les filtres dédiés aux assets (<code translate=\"no\">resize</code>, <code translate=\"no\">minify</code>, <code translate=\"no\">fingerprint</code>, <code translate=\"no\">to_css</code>, <code translate=\"no\">inline</code>, <code translate=\"no\">webp</code>, <code translate=\"no\">lqip</code>, etc.) sont documentés dans la section <a href=\"../../assets/index.fr.md\">Assets</a>.</p></aside>\n<h2 id=\"filter-by\">filter_by<a class=\"heading-anchor\" href=\"#filter-by\" aria-hidden=\"true\" tabindex=\"-1\"></a></h2>\n<p>Filtre une collection de pages par nom/valeur de variable.</p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-variable\">{{ collection|filter_by(variable, value) }}</span></code></pre>\n<p>Seules les pages standards (de type <code translate=\"no\">page</code>, hors redirections) sont renvoyées.</p>\n<p><em>Exemple :</em></p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-variable\">{{ pages|filter_by('section', 'blog') }}</span></code></pre>\n<h2 id=\"filter\">filter<a class=\"heading-anchor\" href=\"#filter\" aria-hidden=\"true\" tabindex=\"-1\"></a></h2>\n<p>Pour les cas plus complexes, il est préférable d’utiliser le filtre natif <a href=\"https://twig.symfony.com/doc/filters/filter.html\" target=\"_blank\" rel=\"noopener noreferrer\"><code translate=\"no\">filter</code></a> de Twig.</p>\n<p><em>Exemple :</em></p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-tag\">{% <span class=\"hljs-name\"><span class=\"hljs-keyword\">set</span></span> filtered = pages|<span class=\"hljs-keyword\">filter</span>(p =&gt; p.generated == false and p.id not in ['page-1', 'page-2']) %}</span></code></pre>\n<h2 id=\"markdown-to-html\">markdown_to_html<a class=\"heading-anchor\" href=\"#markdown-to-html\" aria-hidden=\"true\" tabindex=\"-1\"></a></h2>\n<p>Convertit une chaîne Markdown en HTML.</p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-variable\">{{ markdown|markdown_to_html }}</span></code></pre>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-tag\">{% <span class=\"hljs-name\"><span class=\"hljs-keyword\">apply</span></span> markdown_to_html %}</span><span class=\"xml\">\n</span><span class=\"hljs-comment\">{# Markdown here #}</span><span class=\"xml\">\n</span><span class=\"hljs-template-tag\">{% <span class=\"hljs-name\"><span class=\"hljs-keyword\">endapply</span></span> %}</span></code></pre>\n<p><em>Exemples :</em></p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-tag\">{% <span class=\"hljs-name\"><span class=\"hljs-keyword\">set</span></span> markdown = '**This is bold text**' %}</span><span class=\"xml\">\n</span><span class=\"hljs-template-variable\">{{ markdown|markdown_to_html }}</span></code></pre>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-tag\">{% <span class=\"hljs-name\"><span class=\"hljs-keyword\">apply</span></span> markdown_to_html %}</span><span class=\"xml\">\n**This is bold text**\n</span><span class=\"hljs-template-tag\">{% <span class=\"hljs-name\"><span class=\"hljs-keyword\">endapply</span></span> %}</span></code></pre>\n<h2 id=\"toc\">toc<a class=\"heading-anchor\" href=\"#toc\" aria-hidden=\"true\" tabindex=\"-1\"></a></h2>\n<p>Extrait uniquement les titres correspondant aux <code translate=\"no\">selectors</code> donnés (h2, h3, etc.), ou à ceux définis dans la configuration <code translate=\"no\">pages.body.toc</code> s’ils ne sont pas spécifiés.\nLe paramètre <code translate=\"no\">format</code> définit le format de sortie : <code translate=\"no\">html</code> (par défaut) ou <code translate=\"no\">json</code>.\nLe paramètre <code translate=\"no\">url</code> est utilisé pour créer les liens vers les titres.</p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-variable\">{{ markdown|toc(format, selectors, url) }}</span></code></pre>\n<p><em>Exemples :</em></p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-variable\">{{ page.body|toc }}</span><span class=\"xml\">\n</span><span class=\"hljs-template-variable\">{{ page.body|toc('html') }}</span><span class=\"xml\">\n</span><span class=\"hljs-template-variable\">{{ page.body|toc(selectors=['h2']) }}</span><span class=\"xml\">\n</span><span class=\"hljs-template-variable\">{{ page.body|toc(url=url(page)) }}</span></code></pre>\n<h2 id=\"json-decode\">json_decode<a class=\"heading-anchor\" href=\"#json-decode\" aria-hidden=\"true\" tabindex=\"-1\"></a></h2>\n<p>Convertit une chaîne JSON en tableau.</p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-variable\">{{ json|json_decode }}</span></code></pre>\n<p><em>Exemple :</em></p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-tag\">{% <span class=\"hljs-name\"><span class=\"hljs-keyword\">set</span></span> json = '{\"foo\": \"bar\"}' %}</span><span class=\"xml\">\n</span><span class=\"hljs-template-tag\">{% <span class=\"hljs-name\"><span class=\"hljs-keyword\">set</span></span> array = json|json_decode %}</span><span class=\"xml\">\n</span><span class=\"hljs-template-variable\">{{ array.foo }}</span></code></pre>\n<h2 id=\"yaml-parse\">yaml_parse<a class=\"heading-anchor\" href=\"#yaml-parse\" aria-hidden=\"true\" tabindex=\"-1\"></a></h2>\n<p>Convertit une chaîne YAML en tableau.</p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-variable\">{{ yaml|yaml_parse }}</span></code></pre>\n<p><em>Exemple :</em></p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-tag\">{% <span class=\"hljs-name\"><span class=\"hljs-keyword\">set</span></span> yaml = 'key: value' %}</span><span class=\"xml\">\n</span><span class=\"hljs-template-tag\">{% <span class=\"hljs-name\"><span class=\"hljs-keyword\">set</span></span> array = yaml|yaml_parse %}</span><span class=\"xml\">\n</span><span class=\"hljs-template-variable\">{{ array.key }}</span></code></pre>\n<h2 id=\"slugify\">slugify<a class=\"heading-anchor\" href=\"#slugify\" aria-hidden=\"true\" tabindex=\"-1\"></a></h2>\n<p>Convertit une chaîne en slug.</p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-variable\">{{ string|slugify }}</span></code></pre>\n<h2 id=\"u\">u<a class=\"heading-anchor\" href=\"#u\" aria-hidden=\"true\" tabindex=\"-1\"></a></h2>\n<p>Le filtre <code translate=\"no\">u</code> enveloppe un texte dans un objet Unicode (une <a href=\"https://symfony.com/doc/current/components/string.html\" target=\"_blank\" rel=\"noopener noreferrer\">instance Symfony UnicodeString</a>) qui expose des méthodes pour « manipuler » la chaîne.</p>\n<p><em>Exemple :</em></p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-variable\">{{ 'cecil_string with twig'|u.camel.title }}</span></code></pre>\n<blockquote>\n<p>CecilStringWithTwig</p>\n</blockquote>\n<h2 id=\"singular\">singular<a class=\"heading-anchor\" href=\"#singular\" aria-hidden=\"true\" tabindex=\"-1\"></a></h2>\n<p>Le filtre <code translate=\"no\">singular</code> transforme un nom donné au pluriel en sa version au singulier.</p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-variable\">{{ string|singular(locale) }}</span></code></pre>\n<p><em>Exemple :</em></p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-comment\">{# English (en) rules are used by default #}</span><span class=\"xml\">\n</span><span class=\"hljs-template-variable\">{{ 'partitions'|singular }}</span></code></pre>\n<blockquote>\n<p>partition</p>\n</blockquote>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-variable\">{{ 'partitions'|singular('fr') }}</span></code></pre>\n<blockquote>\n<p>partition</p>\n</blockquote>\n<h2 id=\"plural\">plural<a class=\"heading-anchor\" href=\"#plural\" aria-hidden=\"true\" tabindex=\"-1\"></a></h2>\n<p>Le filtre <code translate=\"no\">plural</code> transforme un nom donné au singulier en sa version au pluriel.</p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-variable\">{{ string|plural(locale) }}</span></code></pre>\n<p><em>Exemple :</em></p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-comment\">{# English (en) rules are used by default #}</span><span class=\"xml\">\n</span><span class=\"hljs-template-variable\">{{ 'animal'|plural }}</span></code></pre>\n<blockquote>\n<p>animals</p>\n</blockquote>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-variable\">{{ 'animal'|plural('fr') }}</span></code></pre>\n<blockquote>\n<p>animaux</p>\n</blockquote>\n<h2 id=\"excerpt\">excerpt<a class=\"heading-anchor\" href=\"#excerpt\" aria-hidden=\"true\" tabindex=\"-1\"></a></h2>\n<p>Tronque une chaîne et ajoute un suffixe.</p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-variable\">{{ string|excerpt(length, suffix) }}</span></code></pre>\n<table>\n<thead>\n<tr>\n<th>Option</th>\n<th>Description</th>\n<th>Type</th>\n<th>Par défaut</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>length</td>\n<td>Tronque après ce nombre de caractères.</td>\n<td>entier</td>\n<td>450</td>\n</tr>\n<tr>\n<td>suffix</td>\n<td>Ajoute des caractères.</td>\n<td>chaîne</td>\n<td><code translate=\"no\">' …'</code> (espace et points de suspension)</td>\n</tr>\n</tbody>\n</table>\n<p><em>Exemples :</em></p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-variable\">{{ variable|excerpt }}</span><span class=\"xml\">\n</span><span class=\"hljs-template-variable\">{{ variable|excerpt(250, '...') }}</span></code></pre>\n<h2 id=\"excerpt-html\">excerpt_html<a class=\"heading-anchor\" href=\"#excerpt-html\" aria-hidden=\"true\" tabindex=\"-1\"></a></h2>\n<p>Lit les caractères avant ou après la balise <code translate=\"no\">&lt;!-- excerpt --&gt;</code> ou <code translate=\"no\">&lt;!-- break --&gt;</code>.\nVoir la <a href=\"../../content/3-markdown.fr.md#extrait\">documentation du contenu</a> pour plus de détails.</p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-variable\">{{ string|excerpt_html({separator, capture}) }}</span></code></pre>\n<table>\n<thead>\n<tr>\n<th>Option</th>\n<th>Description</th>\n<th>Type</th>\n<th>Par défaut</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>separator</td>\n<td>Chaîne à utiliser comme séparateur.</td>\n<td>chaîne</td>\n<td><code translate=\"no\">excerpt|break</code></td>\n</tr>\n<tr>\n<td>capture</td>\n<td>Partie à capturer, <code translate=\"no\">before</code> ou <code translate=\"no\">after</code> le séparateur.</td>\n<td>chaîne</td>\n<td><code translate=\"no\">before</code></td>\n</tr>\n</tbody>\n</table>\n<p>Les valeurs par défaut sont définies par la configuration <code translate=\"no\">pages.body.excerpt</code>.</p>\n<p><em>Exemples :</em></p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-variable\">{{ variable|excerpt_html }}</span><span class=\"xml\">\n</span><span class=\"hljs-template-variable\">{{ variable|excerpt_html({separator: 'excerpt|break', capture: 'before'}) }}</span><span class=\"xml\">\n</span><span class=\"hljs-template-variable\">{{ variable|excerpt_html({capture: 'after'}) }}</span></code></pre>\n<h2 id=\"absolute-urls\">absolute_urls<a class=\"heading-anchor\" href=\"#absolute-urls\" aria-hidden=\"true\" tabindex=\"-1\"></a></h2>\n<p>Rend absolues les URL relatives à la racine (ex. : <code translate=\"no\">/about/</code>, <code translate=\"no\">/images/photo.png</code>) des attributs <code translate=\"no\">href</code>, <code translate=\"no\">src</code> et <code translate=\"no\">srcset</code> d'un contenu HTML, avec le schéma et l'hôte de la <code translate=\"no\">baseurl</code>, pour utiliser le contenu en dehors du site (flux, e-mails, etc.).</p>\n<p>Les autres URL (URL absolues ou relatives au protocole, chemins relatifs, ancres, <code translate=\"no\">mailto:</code>, <code translate=\"no\">data:</code>, etc.) sont conservées telles quelles, et le contenu n'est pas modifié si la <code translate=\"no\">baseurl</code> n'est pas absolue.</p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-variable\">{{ string|absolute_urls }}</span></code></pre>\n<p><em>Exemple :</em></p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-comment\">{# avec `baseurl: https://example.com/` #}</span><span class=\"xml\">\n</span><span class=\"hljs-template-variable\">{{ '&lt;a href=\"/about/\"&gt;À propos&lt;/a&gt; &lt;img src=\"/images/photo.png\" srcset=\"/images/photo-320.png 320w\"&gt;'|absolute_urls }}</span><span class=\"xml\">\n</span><span class=\"hljs-comment\">{# &lt;a href=\"https://example.com/about/\"&gt;À propos&lt;/a&gt; &lt;img src=\"https://example.com/images/photo.png\" srcset=\"https://example.com/images/photo-320.png 320w\"&gt; #}</span></code></pre>\n<aside class=\"note note-info\"><p>Les flux intégrés (Atom, RSS et JSON Feed) appliquent ce filtre au contenu de leurs éléments.</p></aside>\n<h2 id=\"highlight\">highlight<a class=\"heading-anchor\" href=\"#highlight\" aria-hidden=\"true\" tabindex=\"-1\"></a></h2>\n<p>Met en surbrillance une chaîne de code.</p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-variable\">{{ code|highlight(language, engine) }}</span></code></pre>\n<p>Le moteur de coloration (<code translate=\"no\">highlightjs</code> ou <code translate=\"no\">tempest</code>) est l’argument optionnel <code translate=\"no\">engine</code> ou, par défaut, l’option <a href=\"../../configuration/7-layouts.fr.md#layouts-highlight\"><code translate=\"no\">layouts.highlight.engine</code></a> (<code translate=\"no\">highlightjs</code> par défaut).</p>\n<aside class=\"note note-tip\"><p>Le filtre n’utilise pas l’option <a href=\"../../configuration/4-pages.fr.md#pages-body-highlight\"><code translate=\"no\">pages.body.highlight.engine</code></a>, qui ne s’applique qu’au contenu Markdown.</p></aside>\n<p>Si le langage n’est pas pris en charge par le moteur, le code est retourné échappé, sans coloration (et un avertissement est journalisé).</p>\n<p><em>Exemples :</em></p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-variable\">{{ '&lt;?php echo $highlighted-&gt;value; ?&gt;'|highlight('php') }}</span><span class=\"xml\">\n</span><span class=\"hljs-template-variable\">{{ '&lt;?php echo $highlighted-&gt;value; ?&gt;'|highlight('php', 'tempest') }}</span></code></pre>\n<aside class=\"note note-info\"><p>Chaque moteur utilise ses propres classes CSS (<code translate=\"no\">hljs-*</code> pour <code translate=\"no\">highlightjs</code>, <code translate=\"no\">hl-*</code> pour <code translate=\"no\">tempest</code>) : la feuille de style doit correspondre au moteur utilisé.</p></aside>\n<h2 id=\"preg-split\">preg_split<a class=\"heading-anchor\" href=\"#preg-split\" aria-hidden=\"true\" tabindex=\"-1\"></a></h2>\n<p>Divise une chaîne en un tableau à l’aide d’une expression régulière (<code translate=\"no\">limit</code> vaut <code translate=\"no\">0</code>, c’est-à-dire sans limite, par défaut).</p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-variable\">{{ string|preg_split(pattern, limit) }}</span></code></pre>\n<p><em>Exemple :</em></p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-tag\">{% <span class=\"hljs-name\"><span class=\"hljs-keyword\">set</span></span> headers = page.content|preg_split('/&lt;br[^&gt;]*&gt;/') %}</span></code></pre>\n<h2 id=\"preg-match-all\">preg_match_all<a class=\"heading-anchor\" href=\"#preg-match-all\" aria-hidden=\"true\" tabindex=\"-1\"></a></h2>\n<p>Effectue une correspondance d’expression régulière et renvoie le groupe pour toutes les correspondances (<code translate=\"no\">group</code> vaut <code translate=\"no\">0</code>, c’est-à-dire la correspondance complète, par défaut).</p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-variable\">{{ string|preg_match_all(pattern, group) }}</span></code></pre>\n<p><em>Exemple :</em></p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-tag\">{% <span class=\"hljs-name\"><span class=\"hljs-keyword\">set</span></span> tags = page.content|preg_match_all('/&lt;[^&gt;]+&gt;(.*)&lt;\\/[^&gt;]+&gt;/') %}</span></code></pre>\n<h2 id=\"hex-to-rgb\">hex_to_rgb<a class=\"heading-anchor\" href=\"#hex-to-rgb\" aria-hidden=\"true\" tabindex=\"-1\"></a></h2>\n<p>Convertit une couleur hexadécimale en RVB : renvoie un tableau avec les clés <code translate=\"no\">red</code>, <code translate=\"no\">green</code> et <code translate=\"no\">blue</code>.</p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-variable\">{{ color|hex_to_rgb }}</span></code></pre>\n<p><em>Exemple :</em></p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-tag\">{% <span class=\"hljs-name\"><span class=\"hljs-keyword\">set</span></span> rgb = '#f00'|hex_to_rgb %}</span><span class=\"xml\">\nrgb(</span><span class=\"hljs-template-variable\">{{ rgb.red }}</span><span class=\"xml\">, </span><span class=\"hljs-template-variable\">{{ rgb.green }}</span><span class=\"xml\">, </span><span class=\"hljs-template-variable\">{{ rgb.blue }}</span><span class=\"xml\">)</span></code></pre>\n<blockquote>\n<p>rgb(255, 0, 0)</p>\n</blockquote>\n<h2 id=\"splitline\">splitline<a class=\"heading-anchor\" href=\"#splitline\" aria-hidden=\"true\" tabindex=\"-1\"></a></h2>\n<p>Divise une chaîne en un tableau de lignes de <code translate=\"no\">max</code> caractères maximum (<code translate=\"no\">18</code> par défaut), sans couper les mots.</p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-variable\">{{ string|splitline(<span class=\"hljs-name\">max</span>) }}</span></code></pre>\n<p><em>Exemple :</em></p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-tag\">{% <span class=\"hljs-name\"><span class=\"hljs-keyword\">for</span></span> line in 'The quick brown fox jumps'|splitline(10) %}</span><span class=\"xml\">\n  </span><span class=\"hljs-template-variable\">{{ line }}</span><span class=\"xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">br</span>&gt;</span>\n</span><span class=\"hljs-template-tag\">{% <span class=\"hljs-name\"><span class=\"hljs-keyword\">endfor</span></span> %}</span></code></pre>\n<blockquote>\n<p>The quick<br>brown fox<br>jumps</p>\n</blockquote>\n<h2 id=\"iterable\">iterable<a class=\"heading-anchor\" href=\"#iterable\" aria-hidden=\"true\" tabindex=\"-1\"></a></h2>\n<p>Convertit une variable en itérable (tableau) : un tableau est renvoyé tel quel, un objet itérable est converti en tableau, et toute autre valeur est placée dans un tableau.</p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-variable\">{{ variable|iterable }}</span></code></pre>\n<p><em>Exemple :</em></p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-tag\">{% <span class=\"hljs-name\"><span class=\"hljs-keyword\">for</span></span> author in page.authors|iterable %}</span><span class=\"xml\">\n  </span><span class=\"hljs-template-variable\">{{ author }}</span><span class=\"xml\">\n</span><span class=\"hljs-template-tag\">{% <span class=\"hljs-name\"><span class=\"hljs-keyword\">endfor</span></span> %}</span></code></pre>\n<h2 id=\"unique\">unique<a class=\"heading-anchor\" href=\"#unique\" aria-hidden=\"true\" tabindex=\"-1\"></a></h2>\n<p>Supprime les valeurs en double d’un tableau de chaînes (sans tenir compte de la casse : la première occurrence est conservée).</p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-variable\">{{ array|unique }}</span></code></pre>\n<p><em>Exemple :</em></p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-variable\">{{ ['PHP', 'php', 'Twig']|unique|<span class=\"hljs-keyword\">join</span>(', ') }}</span></code></pre>\n<blockquote>\n<p>PHP, Twig</p>\n</blockquote>\n<h2 id=\"duration-to-iso8601\">duration_to_iso8601<a class=\"heading-anchor\" href=\"#duration-to-iso8601\" aria-hidden=\"true\" tabindex=\"-1\"></a></h2>\n<p>Convertit une durée en secondes en <a href=\"https://fr.wikipedia.org/wiki/ISO_8601#Durée\" target=\"_blank\" rel=\"noopener noreferrer\">durée ISO 8601</a> (ex. : pour la <code translate=\"no\">duration</code> d’une vidéo dans les données structurées).</p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-variable\">{{ seconds|duration_to_iso8601 }}</span></code></pre>\n<p><em>Exemple :</em></p>\n<pre data-lang=\"twig\"><code class=\"language-twig hljs twig\" translate=\"no\"><span class=\"hljs-template-variable\">{{ 125|duration_to_iso8601 }}</span></code></pre>\n<blockquote>\n<p>PT00H00M125S</p>\n</blockquote>",
      "language": "fr"
    }
  ]
}
