mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-04 12:51:41 -05:00
24 lines
477 B
Ruby
24 lines
477 B
Ruby
|
require_dependency 'email_styles'
|
||
|
|
||
|
class EmailRenderer
|
||
|
|
||
|
def initialize(message)
|
||
|
@message = message
|
||
|
end
|
||
|
|
||
|
def text
|
||
|
@text ||= @message.body.to_s.force_encoding('UTF-8')
|
||
|
end
|
||
|
|
||
|
def html
|
||
|
formatted_body = EmailStyles.new(PrettyText.cook(text, environment: 'email')).format
|
||
|
|
||
|
ActionView::Base.new(Rails.configuration.paths["app/views"]).render(
|
||
|
template: 'email/template',
|
||
|
format: :html,
|
||
|
locals: { html_body: formatted_body }
|
||
|
)
|
||
|
end
|
||
|
|
||
|
end
|