<p>So I tried it, made three files, one extending the first, and another extending the second, and it all worked more or less as one would expect.</p>

<p>bozo.html</p>

<pre><code>&lt;!DOCTYPE HTML&gt;
&lt;html&gt;
  &lt;head&gt;
    {% set title = title ~ 'Main' %}
    &lt;title&gt;{{ title }}&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
    Where was {% block whereWasBozo %}Bozo?{% endblock whereWasBozo %}&lt;br&gt;
    Variable A is {{ a }}
  &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>ex1_bozo.html</p>

<pre><code>{% extends 'bozo.html' %}
{% set title = title ~ 'Bozo 1 = ' %}
{% set a = 'ex1' %}
{% block whereWasBozo %}
  Bozo wasn't here. 
{% endblock whereWasBozo %}
</code></pre>

<p>ex2_bozo.html</p>

<pre><code>{% extends 'ex1_bozo.html' %}
{% set title = 'Bozo 2 + ' %}
{% set a = 'ex2' %}
{% block whereWasBozo %}
Bozo was in Bozoland.
{% endblock %}
</code></pre>

<p>When I pulled up page ex2_bozo.html, the end result was the page title said: </p>

<pre><code>Bozo 2 + Bozo 1 = Main
</code></pre>

<p>and the web page said:</p>

<pre><code>Where was Bozo was in Bozoland.
Variable A is ex1
</code></pre>

<p>So the blocks extend all the way through. The variables are first set in the file you initially call. They are modified in the middle 'extension' and modified again in the final extension.</p>

CC BY-SA 3.0
2015-06-18T03:41:59.250Z
2015-06-18T03:41:59.250Z
kr37
<p>If <code>template2.html</code> contains <code>{% extends 'template1.html' %}</code> 
and <code>template3.html</code> contains <code>{% extends 'template2.html' %}</code>, what happens to things like <code>{% block %}{% endblock %}</code> and variables?</p>

CC BY-SA 3.0
2015-06-17T22:48:19.870Z
Thanks for sharing! Although, this isn't a "question", per se, and doesn't currently fit the format of this site. If you'd like to edit the question (so it's actually asking a question) and **answer your own question**, we'll be able to keep this thread open.
Lindsey D
CC BY-SA 3.0
2015-06-18T01:27:03.310Z
I'm voting to close this question as off-topic because it is not a question.
Aaron Berkowitz
CC BY-SA 3.0
2015-06-18T17:49:38.670Z
Since this has been fixed, I'm voting to "leave open".
Lindsey D
<templating><extends>
What happens when extending an extended template?
# What happens when extending an extended template?

(Asked by: username_0 on 2015-06-17)

If `template2.html` contains `{% extends 'template1.html' %}`
and `template3.html` contains `{% extends 'template2.html' %}`, what happens to things like `{% block %}{% endblock %}` and variables?

**Tags:** templating, extends

> **Comments:**
> **username_1**: Thanks for sharing! Although, this isn't a "question", per se, and doesn't currently fit the format of this site. If you'd like to edit the question (so it's actually asking a question) and **answer your own question**, we'll be able to keep this thread open.  
> **username_2**: I'm voting to close this question as off-topic because it is not a question.  
> **username_1**: Since this has been fixed, I'm voting to "leave open".  

---

## 1 answers

### Answer by username_0 on 2015-06-18. Score: 3 | Accepted answer

So I tried it, made three files, one extending the first, and another extending the second, and it all worked more or less as one would expect.
bozo.html


  
    {% set title = title ~ 'Main' %}
    {{ title }}
  
  
    Where was {% block whereWasBozo %}Bozo?{% endblock whereWasBozo %}
    Variable A is {{ a }}
  


ex1_bozo.html
{% extends 'bozo.html' %}
{% set title = title ~ 'Bozo 1 = ' %}
{% set a = 'ex1' %}
{% block whereWasBozo %}
  Bozo wasn't here. 
{% endblock whereWasBozo %}

ex2_bozo.html
{% extends 'ex1_bozo.html' %}
{% set title = 'Bozo 2 + ' %}
{% set a = 'ex2' %}
{% block whereWasBozo %}
Bozo was in Bozoland.
{% endblock %}

When I pulled up page ex2_bozo.html, the end result was the page title said: 
Bozo 2 + Bozo 1 = Main

and the web page said:
Where was Bozo was in Bozoland.
Variable A is ex1

So the blocks extend all the way through. The variables are first set in the file you initially call. They are modified in the middle 'extension' and modified again in the final extension.


---

