Machnij sobie template.twig i pliki rozszerzaj o ten szablon.
W template.twig możesz użyć:
{% include 'templates/navbar.twig' %}
A w templates/navbar.twig zamieścić kod HTML z bootstrap'a.
Każdy plik rozszerzony o template.twig będzie automatycznie zawierał menu.
Rozszerzasz w ten sposób:
{% extends 'template.twig' %}
Przetestuj.
Stwórz 3 pliki:
- template.twig
- homepage.twig
- templates/navbar.twig
template.twig:
<!DOCTYPE html>
<html lnag="pl">
<head>
<meta charset="UTF-8">
<title>Witaj Świecie</title>
</head>
<body>
{% include 'templates/navbar.twig' %}
{% block body %}
{% endblock %}
</body>
</html>
homepage.twig:
{% extends 'template.twig' %}
{% block body %}
<h1>Witaj Świecie!</h1>
{% endblock %}
templates/navbar.twig:
<nav>
<ul>
<li>Menu!</li>
</ul>
</nav>