Adam Loving
Adam Loving

Reputation: 443

How do I set a maximum line length for Rails Slim HTML email templates?

I'm using Slim as the templating language for my HTML email. When pretty mode is turned off in production, it puts all the HTML on one line. When the emails go through Sendgrid, a line break is introduced at the 998th character, breaking the HTML. Sendgrid does this to comply with the email RFC.

How can I turn pretty mode off while rendering the email, tell Slim to respect the maximum line length, or introduce a hard line break?

Upvotes: 4

Views: 1185

Answers (2)

ixti
ixti

Reputation: 144

Just add data-force-encoding="✓" attribute to the body tag. That will make Rails to send email as quoted printable (trick is to use UTF8 char in fact). See: https://github.com/slim-template/slim/issues/123

Upvotes: 2

Adam Loving
Adam Loving

Reputation: 443

Adding a few of these

= "\r\n"

throughout the email template solved the problem.

Upvotes: 5

Related Questions