因爲我不想讓我的任何行超過80列,所以我想將最後一行分成兩行。在行尾添加逗號的方式如建議here那樣工作,但逗號出現在字符串內部。用HAML做這件事是否有一個很好和乾淨的方法?HAML中的多行字符串
- if object.errors.any?
%section.form_error_message
%h4.form_error_message__title
= "#{pluralize(object.errors.size, 'errors')} prevented this form from submitting. Please fix these errors and try again."
我想把它全部塞進80列,就像它們在這個截圖的左邊。
如果這些是您稍後想要翻譯的文本,那麼您現在可以切換到使用I18n。那麼你沒有這樣的問題。 – Raffael
或者,您可以使用':ruby'塊將視圖模板中的字符串保存在視圖模板的局部變量中。 – Raffael
謝謝,你說得對,我現在不妨看看國際米蘭。我不認爲我的第一個Rails應用程序會永遠完成,因爲我不斷遇到另一個寶石納入或另一個最佳做法(不是這是一件壞事!) –