我想創建一個紅寶石的方法來處理我的超薄博客文章塊引用。現在,我有以下視圖助手:中間人blockquote紅寶石功能
def blockquote(content,author,source=nil,source_link=nil)
data = '
<blockquote>
<p>'+content.html_safe+'</p>
<footer>
<strong>'+author+'</strong>'
if source && source_link
data = data + '
<cite>
<a href="'+source_link+'">'+source+'</a>
</cite>
'
end
data = data + '</footer></blockquote>'
return data
end
這對於像帖子工程..
= blockquote("When you grow up you tend to get told that the world is the way it is and you're life is just to live your life inside the world. Try not to bash into the walls too much. Try to have a nice family life, have fun, save a little money. That's a very limited life. Life can be much broader once you discover one simple fact: Everything around you that you call life was made up by people that were no smarter than you. And you can change it, you can influence it… Once you learn that, you'll never be the same again.","Steve Jobs, Apple Computers")
然而,會有一個更好的辦法?我想包裝的文字像
- blockquote
When you grow up you tend to get told that the world is the way it is and you're life is just to live your life inside the world. Try not to bash into the walls too much. Try to have a nice family life, have fun, save a little money. That's a very limited life. Life can be much broader once you discover one simple fact: Everything around you that you call life was made up by people that were no smarter than you. And you can change it, you can influence it… Once you learn that, you'll never be the same again.
但我需要一種方式來傳遞作者,並選擇源+源鏈接。
當前的方法還需要報價在一條線上,而不是多條線。思考?
是的,這正是,我一直在尋找,謝謝! – 2014-09-02 02:49:13
我現在得到這個錯誤:== Middleman正在加載 /Users/chrishough/BusinessNoConformity/CodeNoConformity/Blog/config.rb:2:in'require':/ Users/chrishough/BusinessNoConformity/CodeNoConformity/Blog/lib /助手/ view_helpers.rb:23:語法錯誤,意外的'\ n',期待=>(SyntaxError) – 2014-09-02 04:31:21
只是問一個新的問題,如果你仍然需要幫助:) – fyz 2014-09-02 22:32:48