【发布时间】:2013-01-23 06:38:31
【问题描述】:
我目前正在查看piece of code from the excellent Rails-composer,但我不明白第 3 行中的 Embedded Ruby 做了什么:
<% flash.each do |name, msg| %>
<% if msg.is_a?(String) %>
<div class="alert alert-<%= name == :notice ? "success" : "error" %>">
<a class="close" data-dismiss="alert">×</a>
<%= content_tag :div, msg, :id => "flash_#{name}" %>
</div>
<% end %>
<% end %>
到目前为止,我已经查看了Ruby documentation,但没有运气。一旦我了解了这段代码的工作原理,我想扩展它以支持所有级别的flash[] 消息。
【问题讨论】:
标签: ruby