def rend(p1, p2)
body = self.body
body = body.gsub(/p1.first_name/, p1.first_name)
body = body.gsub(/p2.first_name/, p2.first_name)
if p1.gender == 'male'
body = body.gsub(/p1.she/, 'he')
body = body.gsub(/p1.her_p/, 'his')
body = body.gsub(/p1.her/, 'him')
body = body.gsub(/p1.herself/, 'himself')
body = body.gsub(/p1.hers/, 'his')
body = body.gsub(/p1.She/, 'He')
body = body.gsub(/p1.Her_p/, 'His')
body = body.gsub(/p1.Her/, 'Him')
body = body.gsub(/p1.Herself/, 'Himself')
body = body.gsub(/p1.Hers/, 'His')
end
if p1.gender == 'female'
body = body.gsub(/p1.she/, 'she')
body = body.gsub(/p1.her_p/, 'her')
body = body.gsub(/p1.her/, 'her')
body = body.gsub(/p1.herself/, 'herself')
body = body.gsub(/p1.hers/, 'hers')
body = body.gsub(/p1.She/, 'She')
body = body.gsub(/p1.Her_p/, 'Her')
body = body.gsub(/p1.Her/, 'Her')
body = body.gsub(/p1.Herself/, 'Herself')
body = body.gsub(/p1.Hers/, 'Hers')
end
if p2.gender == 'male'
body = body.gsub(/p2.she/, 'he')
body = body.gsub(/p2.her_p/, 'his')
body = body.gsub(/p2.her/, 'him')
body = body.gsub(/p2.herself/, 'himself')
body = body.gsub(/p2.hers/, 'his')
body = body.gsub(/p2.She/, 'He')
body = body.gsub(/p2.Her_p/, 'His')
body = body.gsub(/p2.Her/, 'Him')
body = body.gsub(/p2.Herself/, 'Himself')
body = body.gsub(/p2.Hers/, 'His')
end
if p2.gender == 'female'
body = body.gsub(/p2.she/, 'she')
body = body.gsub(/p2.her_p/, 'her')
body = body.gsub(/p2.her/, 'her')
body = body.gsub(/p2.herself/, 'herself')
body = body.gsub(/p2.hers/, 'hers')
body = body.gsub(/p2.She/, 'She')
body = body.gsub(/p2.Her_p/, 'Her')
body = body.gsub(/p2.Her/, 'Her')
body = body.gsub(/p2.Herself/, 'Herself')
body = body.gsub(/p2.Hers/, 'Hers')
end
body
end
我不太明白問題是什麼。如果文本是模板,請將其作爲模板,並使用erb/equivalent。否則,您需要使用當前上下文使用字符串插值進行評估,但這看起來像目前爲止的模板問題。 – 2013-03-08 19:44:23