I am pretty new to twig and have been giving it a go. Everything was fine until template overrides, and I can't seem for the life of me to figure out why.
Link to twig documentation for what I want to accomplish http://twig.sensiolabs.org/doc/templates.html#template-inheritance
index.php
<?php
//get twig instance
require_once 'Twig/autoloader.php';
Twig_Autoloader::register();
//declare template directory
$loader = new Twig_Loader_Filesystem('templates');
$twig = new Twig_Environment($loader);
echo $twig->render('base.twig');
base.twig
<!DOCTYPE html>
<html>
<head>
</head>
<body>
{% block content %}
<p>Default content block</p>
{% endblock %}
</body>
</html>
override.twig
{% extends 'base.twig'%}
{% block content %}
<p>Content block override</p>
{% endblock %}
Project Folder Structure
- ProjectFolder
- Twig (the library)
-
templates
-- base.twig
-- override.twig
- index.php