I have been following the documentation, tutorials, and some youtube videos, I can never get block nesting and "Extends" to work. Aside from that Timber seems to be working properly.
In the views folder I have these 2 files:
base.twig
test.twig
in base.twig
{% block content %}
........
{% endblock %}
in test.twig
{% extends "base.twig" %}
{% block content %}
This is a test
{% endblock %}
From what I have been following, the code is correct, and I should get an output of "This is a test", right? But instead I still get ".....".
----EDIT----
Ok I figured out some the problem, in my php file I was rendering base.twig. Which apparently didn't do anything to associate test.twig. So when I render test.twig I get the behavior I'm looking for.
However that doesn't explain how to do multiple block nesting... I can nest several files deep inside the same block.. But what if you have two separate blocks in the same twig file? What is the method for dealing with multiple blocks? I can't find documentation on that or any case examples.
Timber::render()
? – GchtrTimber::render( 'base.twig', $context );
and I found out I have to render the test.twig for it to work. However I'm still not clear then how to manipulate multiple block elements in the same twig file. I edited my original post. – RandymWebDevblock head
and ablock footer
in the same twig file. So I would assume that I could have 2 separate twig files that extend for each of those blocks. But I guess that is wrong, so I could only have one child twig file that will extend to both of those block elements? Is that the way things are done? – RandymWebDev