How do I merge 2 twig templates

194 Views Asked by At

Is there a possibility or workaround how to merge 2 twig templates? (NOT render!)

To give more context, let's assume I have base.twig:

<!DOCTYPE html>
<html>
<head>
    <title>{{ title }}</title>
</head>
<body>
    <div id="content">{% block content %}{% endblock %}</div>
</body>
</html>

and a child content.twig:

{% extends "base.twig" %}

{% block content %}
    <h1>Hello {{ username }}</h1>
{% endblock %}

Expected result:

<!DOCTYPE html>
<html>
<head>
    <title>{{ title }}</title>
</head>
<body>
    <div id="content">
        <h1>Hello {{ username }}</h1>
    </div>
</body>
</html>
0

There are 0 best solutions below