@jodator has a good approach.
Alternatively you can use PHP in your Volt template
<script id="template-upload" type="text/x-tmpl">
<?php foreach (.....) { ?>
<tr class="template-upload fade">
<td>
<span class="preview"></span>
........//Some similar code here
</td>
</tr>
<?php } ?>
</script>
The only issue here is that you have to be careful on what the scope of your variables are so that PHP can process them. For instance if o.files
is a javascript object then you need to pass it as a variable in PHP. If it is a PHP object then all you will have to do is change it to $o.files