0
我该如何将它转换为haml?如何将这个erb转化为haml?
<div class="alert alert-<%= name == :notice ? "success" : "error" %>">
我该如何将它转换为haml?如何将这个erb转化为haml?
<div class="alert alert-<%= name == :notice ? "success" : "error" %>">
像这样的事情?
.alert{ class: "alert-#{name == :notice ? 'success' : 'error' }" }
或者,也许这看起来整洁:
%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}" }
您可以使用http://html2haml.heroku.com/ – mohamagdy