Skip to content

Instantly share code, notes, and snippets.

@Tom32i
Last active December 16, 2015 03:49
Show Gist options
  • Save Tom32i/5372515 to your computer and use it in GitHub Desktop.
Save Tom32i/5372515 to your computer and use it in GitHub Desktop.
Twig : isoler un template lors de l'include.
{# template.html.twig #}
{% set title = 'Mon titre' %}
{% set username = 'Jane Doe' %}
<h1>{{ title }}</h1>
<p>{{ username }}</p>
{% include 'user.html.twig' with {title: username} only %}
{# user.html.twig #}
<h2>{{ title }}</h2>
{# La variable title contient 'Jane Doe'. #}
{# La variable username n'existe pas. #}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment