2015-09-22 24 views
0

我還是新來haml,想知道如何轉換這行代碼才能正常工作。我正在使用設計來獲取註冊頁面。如何將這一行的erb轉換爲haml?

<em>(<%= @minimum_password_length %> characters minimum)</em> 

當我離開erb中的代碼時,頁面工作正常,但嘗試將其轉換爲haml後,我在此行發生錯誤。我試過下面的代碼

%em 
    = @minimum_password_length + (characters minimum) 

但我得到一個錯誤說

undefined local variable or method `minimum' 

當我嘗試沒有括號我得到一個錯誤說提前

syntax error, unexpected tIDENTIFIER, expecting keyword_do or '{' or '(' 

謝謝!

+0

http://html2haml.herokuapp.com/ –

回答

1

如果你想字符之間或在字符串中嵌入Ruby中,你可以使用字符串插值文本塊中:

%em 
    | (#{@minimum_password_length} chars minimum)