我的 Sinatra 应用程序中有一个代码
- if flash[:error]
.alert.alert-error
%button.close{:type =>" button", "data-dismiss"=>"alert"}x
= flash[:error]
- if flash[:warning]
.alert.alert-warning
%button.close{:type =>" button", "data-dismiss"=>"alert"}x
= flash[:warning]
- if flash[:info]
.alert.alert-info
%button.close{:type =>" button", "data-dismiss"=>"alert"}x
= flash[:info]
有什么办法可以简单的吗?:type =>" button", "data-dismiss"=>"alert"
特别是,有没有办法通过将它们存储为变量来摆脱重复的哈希初始化?