Mine
public text v1 · immutable{foreach from=$all_sections key=section item=subsections}
{cycle assign=col values='col1,col2,col3'}
{foreach from=$subsections key=code item=subsection}
{capture assign=temp}some text{/capture}
{if $col == 'col1'}
{assign var='col1' value="`$col1``$section``$temp`"}
{elseif $col == 'col2'}
{assign var='col2' value="`$col2``$section```$temp`"}
{elseif $col == 'col3'}
{assign var='col3' value="`$col3``$section```$temp`"}
{/if}
{/foreach}
{/foreach}