我正在使用 rails ActionText 为所有参与者创建培训邀请电子邮件。这些电子邮件包含有关培训的自定义附件(例如培训日期/时间等),还包含某种称呼,例如
亲爱的#first_name
当以电子邮件的形式发送这些邀请时,我想将占位符 #first_name 替换为数据库中的实际名称。
@training.action_text_invitation_text.body.to_s.gsub('#first_name', 'John')
问题:输出 get 转换为 String 类,并且不再输出自定义附件的内容(只是<action-text-attachment>
,但没有内容。方法也是如此to_html
。
我一直在考虑扩展 ActionText::Content 类。但不确定如何做到这一点?
module ActionText
class Content
def custom_render
... replace the certain keywords
end
end
end