use markdown to render html in email body

This commit is contained in:
Kiara Grouwstra 2023-03-13 00:28:13 +01:00
parent 78b27848c2
commit 93be4f5f7f
Signed by: kiara
GPG Key ID: 47D3B7604FFCA83A
1 changed files with 7 additions and 2 deletions

View File

@ -1,12 +1,17 @@
require 'rdoc/rdoc'
class RoomMailer < ApplicationMailer
def invite
formatter = RDoc::Markup::ToHtml.new(RDoc::Options.new, nil)
@room = Room.find(params[:room_id])
@user = params[:user]
@url = params[:url]
md = render inline: @room.email_body
html = RDoc::Markdown.parse(md).accept(formatter)
mail(to: "\"#{ @user.name }\" <#{ @user.email }>", subject: @room.email_subject) do |format|
# format.html { render 'another_template' }
format.text { render inline: @room.email_body }
format.html { html }
format.text { md }
end
end
end