2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-05 08:59:27 +08:00

Merge pull request #1234 from stephankaag/template_args

Determine template_args only once per instance
This commit is contained in:
Robin Ward 2013-07-22 12:20:23 -07:00
commit 5398553628

View file

@ -11,10 +11,23 @@ module Email
end end
class MessageBuilder class MessageBuilder
attr_reader :template_args
def initialize(to, opts=nil) def initialize(to, opts=nil)
@to = to @to = to
@opts = opts || {} @opts = opts || {}
@template_args = {site_name: SiteSetting.title,
base_url: Discourse.base_url,
user_preferences_url: "#{Discourse.base_url}/user_preferences" }.merge!(@opts)
if @template_args[:url].present?
if allow_reply_by_email?
@template_args[:respond_instructions] = I18n.t('user_notifications.reply_by_email', @template_args)
else
@template_args[:respond_instructions] = I18n.t('user_notifications.visit_link_to_respond', @template_args)
end
end
end end
def subject def subject
@ -35,22 +48,6 @@ module Email
body body
end end
def template_args
@template_args ||= { site_name: SiteSetting.title,
base_url: Discourse.base_url,
user_preferences_url: "#{Discourse.base_url}/user_preferences" }.merge!(@opts)
if @template_args[:url].present?
if allow_reply_by_email? and
@template_args[:respond_instructions] = I18n.t('user_notifications.reply_by_email', @template_args)
else
@template_args[:respond_instructions] = I18n.t('user_notifications.visit_link_to_respond', @template_args)
end
end
@template_args
end
def build_args def build_args
{ to: @to, { to: @to,
subject: subject, subject: subject,