The tag #foreach has to be typed before using the Transsmart variables ($item.get('example')) and the tag #end has to be typed after all variables. This makes that the email that is sent is filled with the right variables out of the shipment.
In HTML you can nest these #foreach and #end anywhere, if they are in the HTML comments. An exception is for using them in the
tag.
Below an example of proper usage in <table>tag:
<table align="left" style="width:100%;">
<thead align="left">
<tr>
<th>Name</th>
<th>Street</th>
<th>Zip code</th>
<th>City</th>
<th>Country</th>
</tr>
</thead>
<tbody>
<!-- #foreach($!item in $!shipments) -->
<tr>
<td>$!item.adr.get('RECV').get('adr_name')</td>
<td>$!item.adr.get('RECV').get('adr_street1')</td>
<td>$!item.adr.get('RECV').get('adr_zip')</td>
<td>$!item.adr.get('RECV').get('adr_city')</td>
<td>$!item.adr.get('RECV').get('adr_country')</td>
</tr>
<!-- #end -->
</tbody>
</table>
</body>
Effect in the track-and-trace email:
In the MyTranssmart editor it will look like this:
The <tr> tag stands for a table row, so if you want to display an item after an item and include data, you should put the variables inside the <td> tags.
The user has a lot of freedom here, above example is just an example of proper usage of HTML code for tables.
In general the user has to be aware of the HTML syntax. Inside the <table> you are not allowed to write open text and use any html tags.
According to the documentation:
Quote:
"The <table> tag defines an HTML table. An HTML table consists of one <table> element and one or more <tr>, <th>, and <td> elements. The <tr> element defines a table row, the <th> element defines a table header, and the <td> element defines a table cell. An HTML table may also include <caption>, <colgroup>, <thead>, <tfoot>, and <tbody> elements."
Only in the <td> tag you have the freedom to use any HTML tag and write open text. But in general we recommend to use our example from above as an example of proper usage.