3
當我在erb-模板文件中使用if語句呈現,if語句評估延遲,這是混合了HTML:Rails的模板渲染ERB if語句不是爲了
<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!
有人能解釋我這種奇怪的行爲嗎?
我很驚訝這在所有工作,應該有一個語法錯誤'<% end if %>'(它應該是'<% end %>') –