Reputation: 14806
I am using slim as the template engine for my rails app and would like to use slim for mailer templates as well.
There is no problem with html mailer templates (views/mailer/default_email.en.html.slim) but, I am not sure how to make the text templates work.
I have placed a text template in views/mailer/default_email.en.text.slim with this content:
Hello,
Your video is ready.
= @url
Thank you,
The A-Team
But the result is parsed as slim HTML, and looks like this:
<Hello>,</Hello><Your>video is ready.</Your><Click>the link below to watch it:</Click>http://watch.thy/video<Thank>you,</Thank><The>A-Team</The>
Other than prefixing every line with a pipe, isnt there a more natural way? I even looked for an embedded plugin (like the markdown one) to say "plain text" but there is none.
Thanks in advance.
Upvotes: 7
Views: 3465
Reputation: 4114
For what it's worth, you can actually go the Slim route without having to prefix each line with a pipe, like so:
|
Hello,
<br><br>
Your video is ready.<br>
#{@url}
<br><br>
Thank you,<br>
The A-Team
I would definitely agree with eugen though, that the text.erb
route is the best fit. Just providing another solution, in case somebody absolutely insisted on doing this in Slim. :-)
Upvotes: 5
Reputation: 9226
Slim was designed to generate HTML, not plain text, so you'll have to either use the pipe prefix for each line or go with .text.erb
templates. I'd use the ERB templates, especially if you don't have a lot of interpolation going on.
Upvotes: 7