Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Cover image for Dynamic sendgrid template for multiple items!
sonu sharma
sonu sharma

Posted on

     

Dynamic sendgrid template for multiple items!

Ever wondered how to add multiple items in sendgrid template ?
For example you need to notify your platform users about list of courses available. Since the number of courses are dynamic you cannot create a static template for it.
Lets take an example of Grocery list template
sendgrid template

The list of items is dynamic.

{"items":[{"name":"onion","quantity":5,},{"name":"potato","quantity":5,},{"name":"chilli","quantity":5,}]}
Enter fullscreen modeExit fullscreen mode

Inorder to iterate over the items of the nested array, sendgrid gives handlebar capbilities. Example code

{{#if items}}<h2style="margin:10px 10px">Grocery items !</h2>  {{#each items}}<divstyle="border:1px solid black;min-width:300px;min-height:50px;padding:10px 10px;margin:10px 10px">        Got to buy {{this.name}}</div>  {{/each}}{{/if}}
Enter fullscreen modeExit fullscreen mode

You can include the similar code to iterate over items and produce a good marketing email templates.

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Full Stack developer, actively programming in golang, reactJS, typeScript ...
  • Location
    karnataka,India
  • Joined

More fromsonu sharma

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp