Twig - Using multiple child templates within parent
I have the following two templates

parent.html

    <ul class="basketItems">
    	{% for item in items %}
       		{{ item | raw }}
    	{% endfor %}
    </ul>

child.html

    <li>
    	<a href="/go/to/my/page">{{ link.title}}</a>
    </li>

Now i would like to have multiple instances of child.html within parent.html. In My php code I have to loop through the children and pass in the link object so that the link.title variable can be populated.

My current code involves me loading in parent.html, then rendering each child and creating a php array, then rendering the parent.html and passing in all the generated html of the children as array entries (see below). Is there any easy way to do this without having to build up a php array of html snippets by possibly using Twig blocks.

    $parent = $twig->loadTemplate("parent.html");
    foreach ($items as $item) {
    	$child = $twig->loadTemplate("child.html");
    	$childHtml[] = $child->render(array('item' => $item));
    }
    $parent->render(array('items' => $childHtml));

Thanks in advance
Twig - Using multiple child templates within parent
===

I have the following two templates

parent.html

    <ul class="basketItems">
    	{% for item in items %}
       		{{ item | raw }}
    	{% endfor %}
    </ul>

child.html

    <li>
    	<a href="/go/to/my/page">{{ link.title}}</a>
    </li>

Now i would like to have multiple instances of child.html within parent.html. In My php code I have to loop through the children and pass in the link object so that the link.title variable can be populated.

My current code involves me loading in parent.html, then rendering each child and creating a php array, then rendering the parent.html and passing in all the generated html of the children as array entries (see below). Is there any easy way to do this without having to build up a php array of html snippets by possibly using Twig blocks.

    $parent = $twig->loadTemplate("parent.html");
    foreach ($items as $item) {
    	$child = $twig->loadTemplate("child.html");
    	$childHtml[] = $child->render(array('item' => $item));
    }
    $parent->render(array('items' => $childHtml));

Thanks in advance