forwardemail / email-templates

Create, preview (browser/iOS Simulator), and send custom email templates for Node.js. Made for @forwardemail, @ladjs, @cabinjs, @spamscanner, and @breejs.
https://forwardemail.net/docs/send-emails-with-node-js-javascript
MIT License
3.67k stars 337 forks source link

Special character in subject.pug #390

Closed chhatch closed 4 years ago

chhatch commented 4 years ago

I trying to use a subject like 'Check this out: Foo & Bar' for a subject line in an email. Part of the subject comes from a variable, mySubject, with the value 'Foo & Bar'. My subject.pug looks like this: != `Check this out: ${mySubject}` But appears as Check this out: Foo & Bar in my test emails.

I'm not sure what else to try. Any idea? Thanks!

niftylettuce commented 4 years ago

I'm not sure what your issue is - your expected and actual output seems to be the same?

chhatch commented 4 years ago

My bad, the subject appears as Check this out: Foo & Bar

niftylettuce commented 4 years ago

What does your subject.pug look like?

It seems to me that since you're using != it should work fine. Is there some sort of encoding going on? Try this to see output debug information in console when you try again:

- console.log('the subject mySubject was', mySubject)
!= `Check this out: ${mySubject}`
niftylettuce commented 4 years ago

Updated example*

chhatch commented 4 years ago

Here's what we got: the subject mySubject was AHA CPR & AED & First Aid What's odd is that span !{mysubject} gives the expected output in html.pug

niftylettuce commented 4 years ago

I don't have time presently but ping me back in 24-48 hours if you still can't figure it out.

You can also run with DEBUG=* flag, or specifically DEBUG=email-templates or DEBUG=preview-email.

chhatch commented 4 years ago

Will do. You've been very helpful so far.

chhatch commented 4 years ago

I solved the issue by grabbing a value on the front end with el.innerText instead of el.innerHTML, which I should have been doing anyway. This was user error. I really appreciate you helping me track down the issue so quickly.

niftylettuce commented 4 years ago

Great!

Obligatory sponsor link https://github.com/sponsors/niftylettuce