Set Parent Template Defined Content to Output in Child Template I have a layout template, we'll call that Template A that is extended by another template, we'll call that Template B that includes another template, we'll call that Template C that includes another template lets call that Template D

So the visually it goes like so:

-Template A

--Template B

---Template C

----Template D

In Template C I define some content such as "Hello World" as well as a bunch of other content.

I do not want Template C to output the "Hello World" content but instead want Template D to decide where it is output as defined in Template C

I'm thinking that somewhere i might should use embed rather than include but i'm a bit hazy on exactly how to achieve this. Any help would be greatly appreciated.

NOTE: The content defined in Template C is defined after Template C includes Template D and also the content that is defined is not just a simple string as indicated above "hello world" but actually much more complex data.

UPDATE: Here is an example of the templates to help better understand the question.

Template C:

{% for block in entry.body.level(1) %}
  {% include 'Template D' %}
  {% if block.children is not empty %}
    {% block child %}
        {% for block in block.children %}
            {% include 'Template E' %}
        {% endfor %}
    {% endblock %}
  {% endif %}
{% endfor %}


Where Template E is the "Hello World" content mentioned above.

Template D:

 {% if block.slide|length %}
     &lt;div class="stuff"&gt;
         &lt;ul class="somestuff"&gt;
             {% for background in block.slide %}
                 &lt;li style="background-image:url({{ background.url() }})"&gt;&lt;/li&gt;
             {% endfor %}
         &lt;/ul&gt;
     &lt;/div&gt;

     &lt;section id="text-slider"&gt;
         &lt;div class="container"&gt;
             {% block child %}{% endblock %}
        &lt;/div&gt;
     &lt;/section&gt;
 {% endif %}


And more code also after that endif. Where Block Child (in Template C) is the content to be defined and Block Child (in Template D) is where i want it output.
You could use include...with, as specified in the Twig Docs here

Example for your case:

{# in Template C #}
{% include 'template-d.twig' with {'foo':'Hello World'} %}


This should give Template D access to foo. Hope that helps!