twig tutorial - twig php - Using a base template in Twig - twig php - twig template



Using a base template

base.twig.html

<!DOCTYPE html>
<html>
    <head>
        <title>{{ title | default('Hello World') }}</title>
        <link rel="stylesheet" type="text/css" href="theme.css">
        {% block css %}
        {% endblock %}
    </head>
    <body>
    {% block body %}
        <nav>
        {% block navigation %}
            <a href="#">Link</a>
            <a href="#">Link</a>
            <a href="#">Link</a>
        {% endblock navigation %}
        </nav>
        <section id="container">
            <section id="content">
            {% block content %}
            <p>
            Lorem ipsum dolor sit amet.
            </p>
        </section>
        {% endblock content %}
    </section>
    {% endblock body %}
    </body>
</html>

page.twig.html

{% extends base.twig.html %}
{% block navigation %}
<a href="page2.html">Page 2</a>
<a href="page3.html">Page 3</a>
<a href="page4.html">Page 4</a>
{% endblock %}
{% block content %}
This is my first page
{% endblock content %}

Related Searches to twig tutorial - Using a base template in Twig