我如何将其转换为haml?
<div class="alert alert-<%= name == :notice ? "success" : "error" %>">
我如何将其转换为haml?
<div class="alert alert-<%= name == :notice ? "success" : "error" %>">
%div{:class => "alert alert-#{name == :notice ? 'success' : 'error' }"}
或者,更干净:
- alert_type = name == :notice ? 'success' : 'error'
%div{ :class => "alert alert-#{alert_type}" }
像这样的东西?
.alert{ class: "alert-#{name == :notice ? 'success' : 'error' }" }
或者这看起来更整洁:
%div{ class: "alert alert-#{name == :notice ? 'success' : 'error' }" }