Using slim for plain text email templates in Rails
diabolo opened this issue · 2 comments
Given the rails email slim template mail.txt.slim with content
Hello World
I'd expect to get a text preview email with content
Hello World
but I get
<Hello>World</Hello>
Rails 7, Ruby 3.0.3
How about wrapping entire text as verbatim text block by |
?
|
Wibble got a new comment on #{{@comment.post.title}}
#{{@comment.content}}
Slim is a templating engine that specializes in generating tree structures like HTML and XML, so it seems a bit strange to use it for plain text, but if you really love Slim, no one can stop you.
$ slimrb --compile << SLIM
> |
> Wibble got a new comment on #{{@comment.post.title}}
> #{{@comment.content}}
> SLIM
_buf = '';
; _buf << ("Wibble got a new comment on ".freeze); _buf << ((@comment.post.title).to_s);
; _buf << ("\n".freeze); _buf << ((@comment.content).to_s);
; _buf
I'll close this as I agree that slim really isn't best suited to text templates, and I understand that what I was asking for is unreasonable for slim to provide.
This bug/issue/non-event came from working on an example app, and it used generators (which I would never normally use). Perhaps slim-rails shouldn't generate text templates for emails.