我如何在haml中执行内联if语句

Mat*_*iby 6 ruby haml ruby-on-rails ruby-on-rails-3

我有这个haml

  %table.form_upper{:style => "display:none;", :id => 'profile-info'}
    %tr{:id => 'some-row'}
Run Code Online (Sandbox Code Playgroud)

如果满足条件,我如何在此表上不显示任何条件,例如我知道我可以这样做但我觉得必须采用内联方式

-if condtion
  %table.form_upper{:id => 'profile-info'}
-else
  %table.form_upper{:style => "display:none;", :id => 'profile-info'}
    %tr{:id => 'some-row'}
Run Code Online (Sandbox Code Playgroud)

Mic*_*ins 13

你可以这样做:

%table.form_upper{:style => "display:#{condition ? 'none' : ''};", :id => 'profile-info'}
Run Code Online (Sandbox Code Playgroud)