- Maizzle Version: latest
- Node.js Version: 18.19.0
Is it possible to have each loops that are not strictly defined at build time?
I am using the templates along with firebase trigger email extension which allows me to pass data to the template via handlebars.
I am trying to send order confirmation emails with a list of all the order items:
<each loop="item, index in @{{orderItems}}">
<table class="w-full">
<tr>
<td class="w-[72px] align-top">
<img
src="{{item.image}}"
alt="{{item.name}}"
width="48"
/>
</td>
<td
class="w-[400px] text-left align-top text-base text-gray-900 sm:w-auto"
>
<p class="m-0 mb-2 font-bold">{{item.name}}</p>
<p class="leading-5.5 m-0 mb-2">{{item.description}}</p>
<p class="m-0 leading-3 text-gray-500">
Qty. {{item.quantity}}
</p>
<p class="leading-5.5 m-0 mt-2 text-gray-500">
PROMO20 (-$20)
</p>
</td>
<td class="text-base/5.5 w-[88px] text-right align-top">
<p class="m-0 mb-2 text-gray-700">
<strike>$99</strike>
</p>
<p class="m-0 font-bold text-gray-900">R{{item.price}}</p>
</td>
</tr>
</table>
<x-spacer height="24px" />
</each>
The @{{orderItems}} variable is provided to the extension (which uses nodemailer) inside of a object named data.
I am able to display everything else- including the payment info, the date, the name and any other attribute I include in the data object, and reference in the template via @{{ propertyName }} .
The issue is that when I build the templates, everything inside of the each tag simply disappears...
Is this because the maizzle framework cant evaluate the @{{orderItems}} array at build time and defaults to ignoring the loop entirely?
Surely this is a common issue? How do other people send order confirmation emails or receipts with a list of items that the customer purchased.
Is it possible to have each loops that are not strictly defined at build time?
I am using the templates along with firebase trigger email extension which allows me to pass data to the template via handlebars.
I am trying to send order confirmation emails with a list of all the order items:
The
@{{orderItems}}variable is provided to the extension (which uses nodemailer) inside of a object nameddata.I am able to display everything else- including the payment info, the date, the name and any other attribute I include in the
dataobject, and reference in the template via@{{ propertyName }}.The issue is that when I build the templates, everything inside of the each tag simply disappears...
Is this because the maizzle framework cant evaluate the
@{{orderItems}}array at build time and defaults to ignoring the loop entirely?Surely this is a common issue? How do other people send order confirmation emails or receipts with a list of items that the customer purchased.