'Loop to build table using Liquid
I have seen in the documentation of Liquid which is exactly what I need but using it to build HTML emails so I need to add inline styles on parts of the HTML like tr and td. Is it possible using the following example? Or is there an alternative Liquid method to achieve this?
It adds classes which is great, but as I am using it for HTML emails, I need to do inline styles also.
<table>
{% tablerow product in collection.products cols:2 %}
{{ product.title }}
{% endtablerow %}
</table>
which outputs
<table>
<tr class="row1">
<td class="col1">
Cool Shirt
</td>
<td class="col2">
Alien Poster
</td>
</tr>
<tr class="row2">
<td class="col1">
Batman Poster
</td>
<td class="col2">
Bullseye Shirt
</td>
</tr>
<tr class="row3">
<td class="col1">
Another Classic Vinyl
</td>
<td class="col2">
Awesome Jeans
</td>
</tr>
</table>
Solution 1:[1]
I would just avoid using that tag, I don't think I've ever actually seen it in use.
Use standard HTML tags and then add your own styles.
<table>
{% for product in collection.products %}
<tr>
<td class="title" style="color: red;">{{ product.title }}</td>
<td class="price" style="color: purple">{{ product.price }}</td>
</tr>
{% endfor %}
</table>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | ConduciveMammal |