twig tutorial - Variable inheritance in Twig - twig php - twig template



Variable inheritance

parent.html.twig

<!DOCTYPE html>
<html>
    <head>
        <title>{{ title_variable | default('Normal Page') }}</title>
    </head>
    <body>
         <h1>This is the {{ title_variable }} Page</h1>    
    </body>
</html>

child.html.twig

{% extends "parent.html.twig" %}
{% set title_variable = "Child" %}

Related Searches to twig tutorial - Variable inheritance in Twig