sendgrid / sendgrid-python

The Official Twilio SendGrid Python API Library
https://sendgrid.com
MIT License
1.55k stars 714 forks source link

Get substitution tags available in template #898

Open escobarjj opened 4 years ago

escobarjj commented 4 years ago

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!

eshanholtz commented 4 years ago

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.

DougCal commented 4 years ago

Going to look into this one

DougCal commented 4 years ago

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?

childish-sambino commented 4 years ago

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.

DougCal commented 4 years ago

Sounds like that approach would be through _GET /templates/{templateid}. Would we want to support _GET /mailsettings/template by chance?

childish-sambino commented 4 years ago

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.