We are in the process of creating an HTML email template that needs to conditionally render markup based on the value of one of the properties from our JSON data. We found the following example where you can create custom Handlebar Helpers to do exactly that, but when using these, AWS SES refuses to send the email.
Here is an example of what we are trying:
<script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/3.0.1/handlebars.min.js">
</script>
<script type="text/x-handlebars-template">
Handlebars.registerHelper("equals", function(string1 ,string2, options) {
if (string1 === string2) {
return options.fn(this);
} else {
return options.inverse(this);
}
});
</script>
{{#equals network "Telkom" }}
<p>This is Telkom {{network}}</p>
{{else}}
This is Not Telkom {{network}}
{{/equals}}
We found this implementation in the following post: Logic in Handlebars if/else statement?
We also did some investigating and found this discussion on the AWS forum that seems to claim that custom handlebar helpers are not supposed by SES https://forums.aws.amazon.com/thread.jspa?messageID=983645
Does anyone perhaps know if this is at all possible, and if not, is there another way to conditionally render the required markup when we send the emails using SES?
I believe that most e-mail clients don't support JavaScript for security reasons. So the rendering of your template will have to be done server side by SES. Is there perhaps some other value in the JSON data that indicates that the data is for a Telkom network or not? If so you could use it in an if statement, as per https://handlebarsjs.com/guide/builtin-helpers.html#if