Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i do an inline if statement in haml

I have this haml

  %table.form_upper{:style => "display:none;", :id => 'profile-info'}
    %tr{:id => 'some-row'}

How do i do display none on this table if a condition is met like for example i know i can do this but i feel there has got to be an inline way of doing this

-if condtion
  %table.form_upper{:id => 'profile-info'}
-else
  %table.form_upper{:style => "display:none;", :id => 'profile-info'}
    %tr{:id => 'some-row'}
like image 446
Matt Elhotiby Avatar asked Apr 15 '12 15:04

Matt Elhotiby


1 Answers

You can do this:

%table.form_upper{:style => "display:#{condition ? 'none' : ''};", :id => 'profile-info'}
like image 84
Michael Shimmins Avatar answered Sep 20 '22 20:09

Michael Shimmins