2014-07-23 57 views

回答

0

我假設你使用redcloth,所以你的用戶/編輯會輸入文本,但他們會得到幾個關鍵字,他們可以輸入,並將在渲染時填寫。例如像author, date, ...,但我當然不知道你的網站是什麼。

最乾淨延遲字符串插值是使用%運算符。

僅供演示了些廢話例如:

some_text = "flap %{cookie} some more %{action} NOW!" 
filled_in_text = some_text % {cookie: 'banana', action: 'eating' } 
Redcloth.new(filled_in_text).to_html 

所以,你會從數據庫中檢索(模型)some_text,什麼用戶/編輯輸入,然後插使用%和可能的哈希(支持的值)。結果你只需交給紅布。