Answers.Body: <p>In my experience, this is the type of situation where you may want to consider having a second layout rather than opting for a more complicated inheritance scheme. If your layouts are somewhat complex and you want to keep your markup DRY I would suggest moving the more complex components of your layout into includes. </p>
  
  <p>Also, when I get beyond the Layout &raquo; Template relationship, instead of defining blocks and extending the Template I opt for includes there as well. This makes my workflow efficient because I always consider the Template to be the base point, inheriting up into the Layout and inheriting down into any includes.</p>
  
  <p>layout_1col.html</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  {% include 'head' %}
  &lt;body&gt;
    {% include 'header' %}
    &lt;main&gt;
      {% block 'main' %}{% endblock %}
    &lt;/main&gt;
    {% include 'footer' %}
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>layout_2col.html</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  {% include 'head' %}
  &lt;body&gt;
    {% include 'header' %}
    &lt;main&gt;
      {% block 'main' %}{% endblock %}
    &lt;/main&gt;
    &lt;aside&gt;
      {% block 'sidebar' %}{% endblock %}
    &lt;/aside&gt;
    {% include 'footer' %}
  &lt;/body&gt;
  </code></pre>
  
  <p>MyTemplate.html</p>
  
  <pre><code>{% extends 'layout_1col' %}
  {% block 'main' %}
    &lt;p&gt;My content&lt;/p&gt;
    {% include 'mywidget' %}
  {% endblock %}
  </code></pre>
  
  <p>By letting your layouts rely heavily on includes you can let them vary only where needed but keeping your inheritance logic simple and easily extended.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-10T18:10:23.267Z
Answers.Text: This is a very nice solution. Thanks for your feedback Michael.
Answers.UserDisplayName: julzmon
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-10T11:39:38.063Z
Answers.LastActivityDate: 2015-03-10T11:39:38.063Z
Answers.UserDisplayName: Michael Thomas
Body: <p>I'm trying to figure out how to nest 3 templates and have them inherit the blocks. How can I sometimes reference the child.html when I need a wrapper and sometimes not reference it. Maybe I'm trying to do this the wrong way? Thank you for your feedback.</p>
  
  <p>parent.html</p>
  
  <pre><code>{% block contentBlock %}
  {% endblock %}
  </code></pre>
  
  <p>child.html</p>
  
  <pre><code>&lt;div&gt;    
  {% extends "parent" %}
  {% block content %}
  &lt;/div&gt;
  </code></pre>
  
  <p>child-child.html</p>
  
  <pre><code>{% extends "child" %}
  {{ title }}
  </code></pre>
  
  <p>child2.html</p>
  
  <pre><code>{% extends "parent.html" %}
  {% block contentBlock %}
  {{ title }}
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-03-10T09:17:27.603Z
Comments.Text: Check out Twig's 'use' inheritance, it might be what you are looking for: http://twig.sensiolabs.org/doc/tags/use.html
Comments.UserDisplayName: Jamie Wade
Tags: <templating>
Title: How do I nest multiple templates while keeping a wrapper for some pages
ThreadText: # How do I nest multiple templates while keeping a wrapper for some pages
  
  (Asked by: username_0 on 2015-03-09)
  
  I'm trying to figure out how to nest 3 templates and have them inherit the blocks. How can I sometimes reference the child.html when I need a wrapper and sometimes not reference it. Maybe I'm trying to do this the wrong way? Thank you for your feedback.
  
  parent.html
  
  ```
  {% block contentBlock %}
  {% endblock %}
  
  ```
  
  child.html
  
  ```
  <div>    
  {% extends "parent" %}
  {% block content %}
  </div>
  
  ```
  
  child-child.html
  
  ```
  {% extends "child" %}
  {{ title }}
  
  ```
  
  child2.html
  
  ```
  {% extends "parent.html" %}
  {% block contentBlock %}
  {{ title }}
  
  ```
  
  **Tags:** templating
  
  > **Comments:**
  > **username_1**: Check out Twig's 'use' inheritance, it might be what you are looking for: http://twig.sensiolabs.org/doc/tags/use.html  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2015-03-10. Score: 3 | Accepted answer
  
  In my experience, this is the type of situation where you may want to consider having a second layout rather than opting for a more complicated inheritance scheme. If your layouts are somewhat complex and you want to keep your markup DRY I would suggest moving the more complex components of your layout into includes.
  
  Also, when I get beyond the Layout » Template relationship, instead of defining blocks and extending the Template I opt for includes there as well. This makes my workflow efficient because I always consider the Template to be the base point, inheriting up into the Layout and inheriting down into any includes.
  
  layout\_1col.html
  
  ```
  <!DOCTYPE html>
  {% include 'head' %}
  <body>
    {% include 'header' %}
    <main>
      {% block 'main' %}{% endblock %}
    </main>
    {% include 'footer' %}
  </body>
  </html>
  
  ```
  
  layout\_2col.html
  
  ```
  <!DOCTYPE html>
  {% include 'head' %}
  <body>
    {% include 'header' %}
    <main>
      {% block 'main' %}{% endblock %}
    </main>
    <aside>
      {% block 'sidebar' %}{% endblock %}
    </aside>
    {% include 'footer' %}
  </body>
  
  ```
  
  MyTemplate.html
  
  ```
  {% extends 'layout_1col' %}
  {% block 'main' %}
    <p>My content</p>
    {% include 'mywidget' %}
  {% endblock %}
  
  ```
  
  By letting your layouts rely heavily on includes you can let them vary only where needed but keeping your inheritance logic simple and easily extended.
  
  > **Comments:**
  > **username_0**: This is a very nice solution. Thanks for your feedback username_2.  
  
  ---
  
  