You can use the splat (*) operator to help define conditional attributes for tags in slim, using hashes containing the attributes to be added.
http://www.rubydoc.info/gems/slim/frames#Splat_attributes__
The splat operator will expand a hash into a set of attributes to be added to the tag. If the hash is empty, no attributes will be added.
For example,
- admin_classes = @User.admin? ? {class: "foo"} : {}
input *admin_classes
if @User.admin? == true, it should render
<input class="foo">
else if @User.admin? == false, it should render
<input>
For attributes like "class" or other attributes that have attribute merging turned on, you can also do something like this:
- admin_classes = @User.admin? ? {class: ["foo","bar"]} : {}
input *admin_classes class="biz"
if @User.admin? == true, it should render
<input class="foo bar biz">
else if @User.admin? == false, it should render
<input class="biz">