I’m just learning Erlang with Chicago Boss and would like to know how could I do something similar to this (in pseudocode):
foreach (items as item)
if (i % 10 == 0)
<tr>
endif
<td>...</td>
if (i++ % 10 == 0)
</tr>
endif
endforeach
in my template?
Erlang is functional language so idiomatic way is do it in functional way. We prepare function which will tabular your data first:
And now we can use it in way:
And than let io subsystem do the rest. The structure above is well known as iolist and if you put it in any io it will be serialized properly in same way as:
If you have thousands of items in table and efficiency is crucial for you can turn all lists constants into binary. You can also turn into binary data in
Data. As last resort you can rewritetabify/2and formatting in more efficient but less readable way.