Without understanding your use case or having the context of your full template and/or Matrix loop, it's very difficult to provide a good answer.
If you only want to "wrap all outputted blocks" in a container, it's as easy as putting the Matrix loop in a container, e.g.:
<div class="wrapper">
{% for block in entry.myMatrixFieldHandle %}
{% switch block.type %}
{% case 'artworkText' %}
...
{% case 'artworkImageSingle' %}
...
{% case 'artworkImageDouble' %}
...
{% case 'artworkFile' %}
{% for asset in block.downloadUrl %}
<a href="{{ asset.getUrl() }}" target="_blank">
<div class="file {{ block.platform }} gutter-bottom--half"></div>
</a>
{% endfor %}
{% endswitch %}
{% endfor %}
</div>
Based on your comments, however, I suspect that what you really want is to only wrap the markup for all your artworkFile
blocks.
If that is the case, you have to consider the fact that if you want to wrap all of the artworkFile
blocks in a single container and not the other block types, then these artworkFile
blocks will necessarily be removed from the general flow/chronology of your overall Matrix field. This may be exactly what you want, or a side effect you haven't considered - just wanted to mention it. (It also means that you could actually just move the artworkFile
blocks to a separate Matrix field altogether, if that'd make any of this easier).
Anyway, there's at least a couple of ways to achieve the above with your current setup.
First, you can opt to remove the artworkFile
switch case from your current Matrix loop, and create a secondary loop which only loops on artworkFile
blocks somewhere else in your template. This secondary loop is then wrapped in a <div class="wrapper">
container, e.g.:
<div class="wrapper">
{% for block in entry.myMatrixFieldHandle.type('artworkFile') %}
{% for asset in block.downloadUrl %}
<a href="{{ asset.getUrl() }}" target="_blank">
<div class="file {{ block.platform }} gutter-bottom--half"></div>
</a>
{% endfor %}
{% endfor %}
</div>
Another option is to leave the artworkFile
switch in your current Matrix loop, but instead of outputting the markup directly, you can cache it in an array – this is done by first putting the markup in a variable by wrapping the block markup in a {% set %}
tag pair, adding that variable to an array declared outside the loop, and finally print the collected markup by joining the contents of that array inside a container, e.g.:
{# Create an empty array outside the loop #}
{% set artworkFileBlocks = [] %}
{% for block in entry.myMatrixFieldHandle %}
{% switch block.type %}
{% case 'artworkText' %}
...
{% case 'artworkImageSingle' %}
...
{% case 'artworkImageDouble' %}
...
{% case 'artworkFile' %}
{# Cache the markup for the artworkFile block to a variable #}
{% set artworkFileBlock %}
{% for asset in block.downloadUrl %}
<a href="{{ asset.getUrl() }}" target="_blank">
<div class="file {{ block.platform }} gutter-bottom--half"></div>
</a>
{% endfor %}
{% endset %}
{# Add the single artworkFile block markup to the array #}
{% set artworkFileBlocks = artworkFileBlocks|merge([artworkFileBlock]) %}
{% endswitch %}
{% endfor %}
{# Echo all artworkFile markup in a common container, whereever you need it #}
<div class="wrapper">
{{ artworkFileBlocks|join('')|raw }}
</div>
<div class="wrapper">{% for block in myMatrixField %}...{% endfor %}</div>
?