2014-07-23 18 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,什么用户/编辑输入,然后插使用%和可能的哈希(支持的值)。结果你只需交给红布。