Using dynamic values within set value -server side

Does anyone know if I can put dynamic content within a block of text read from a database field?

I have a table that stores the HTML “sections” to construct an email, by combining the various HTML sections, that I then send to users (order confirmations etc.).

This is in a server API where I combine the various HTML snippets and add repeat sections (such as lists of products ordered), to build the email body and then send but I would like to replace some static values in the HTML snippets with dynamic values (e.g. the delivery address, contact details etc).

An example of a bit of the HTML snippet would be -

<div class="col"
                                    style="display:inline-block;width:100%;max-width:270px;vertical-align:top;text-align:left;font-family:Arial,sans-serif;font-size:16px;line-height:22px;color:#363636;">
                                    <h3>Your Invoice Address</h3>
                                    <p>invoice Name</p>
                                    <p>invoice Line1</p>
                                    <p>Invoice Line2</p>
                                    <p>Invoice Town</p>
                                    <p>Invoice County</p>
                                    <p>Invoice postcode</p>
                                    <H4>Invoice Contact Details</H4>
                                    <p>Invoice Contact Name</p>
                                    <p>Invoice Contact Number</p>
                                    <p>Invoice Contact Email</p>
                                </div>

I would like to replace all the order elements (e.g. “Invoice Name”, “Invoice Line1”, “Invoice Line2” etc.) with fields from my orders table.
I have queried the table and have the fields but can’t figure out how to add a reference to the queried fields within the stored HTML snippet so I don’t have to “build” the HTML

Tried {{order_and_user.invoice_name}} and +{{order_and_user.invoice_name}}+ and dmx.parse('order_and_user.invoice_name') but can’t seem to guess the correct format.

Is this possible?

Community Page
Last updated: