sendgrid-python icon indicating copy to clipboard operation
sendgrid-python copied to clipboard

Get substitution tags available in template

Open escobarjj opened this issue 5 years ago • 6 comments

Hi! Is there a way to get all the substitution tags in a specific template?

I want to make sure I am sending all the required information for my template before sending emails.

Thanks!

escobarjj avatar May 23 '20 03:05 escobarjj

This functionality is not currently built into the library. You could do something like get the template body, and parse the unique occurences of your {{handlebar_tags}} and make sure you have an entry for each one before sending the email. Pull requests to add this feature are welcome and will be reviewed based on priority, but Twilio SendGrid is not actively building new functionality for the library.

eshanholtz avatar May 26 '20 23:05 eshanholtz

Going to look into this one

DougCal avatar Aug 07 '20 14:08 DougCal

Would the idea of this be something like adding an additional method that would get only the substitution tags that are inside a template, and leave out any substitution tags that are not in a template?

DougCal avatar Aug 07 '20 15:08 DougCal

I'm thinking a method that GETs the template and returns a set of all the substitution tags found in the template. Users can then use this set to determine if they've populated them all in the mail-send request.

childish-sambino avatar Aug 07 '20 15:08 childish-sambino

Sounds like that approach would be through GET /templates/{template_id}. Would we want to support GET /mail_settings/template by chance?

DougCal avatar Aug 13 '20 14:08 DougCal

I think not, given that it's a legacy feature, but I'm not totally against it. Could make it an option for the new method.

childish-sambino avatar Aug 13 '20 15:08 childish-sambino