Closed camuthig closed 6 years ago
Are you using double {{
or triple {{{
curlies for the variable? Doubles escape html (it's a feature) while triples pass any html through.
Since you're passing in the entire body for each message anyway, I'd question the value of using a stored template. Have you considered using an inline template?
Ah, you are correct in the number of curlies. I had two instead of three. I was porting code over from PHP to Go, and I believed I saw different behavior when sending the JSON with PHP, which doesn't alter the JSON when sending HTML like Go. What seems more likely is I just altered my template at some point without realizing it.
Sorry to waste your time on this one.
Your suggestion of using the inline template is also helpful. What I'm working on right now is really HTML partials instead of the entire email, but I attempted to simplify the testcase for brevity.
Hey, I'm trying to use the
Send
function on the client with a template and send HTML as part of one of my substitution values. My HTML template on SparkPost is justhtml
, so whatever I send in that substitution value will be the entirety of my email message, and myTransmission
is built something likeWhen this request is sent over the API,
json.Marshal
is escaping the HTML special characters, and they are not being unescaped on the SparkPost service. This means my email is literally showing me<strong>HTML</strong>
, and the raw value of the MIME content is<strong>HTML</strong>
.I'm just learning go, so I'm not sure if there is a way for me to avoid this behavior in
json.Marshal
, but so far I have no been able to figure anything out.