3

erb- テンプレート ファイルで if ステートメントを使用している場合、if ステートメントの評価が遅れ、html が混同されます。

<small>
<% if @applause_count == 1 %>
    The author has been cheered up once!
<% elsif @applause_count > 1%> 
    The author has been cheered up <%=  @applause_count %> times! <br/>Be the next!
<% end if %> 
</small>

生成:

<small>
</small>
The author has been cheered up 100 times! <br/>Be the next!

誰かが私にこの奇妙な行動を説明できますか?

4

1 に答える 1