I’ve been looking around how to add an id selector to a link_to helper using haml, is that possible?
a .haml - %a#booked{:href => "index.haml"} Link 1
b .html.erb - booking.html.erb - <%= link_to "Link 1", booking_path, :id => "booked" %>
c .haml.erb - booking.haml.erb - ...??
Which would be the equivalent of b in haml?
link_toworks exactly the same way in haml as it does in erb. So this will do what you want:You can also assign a class attribute in this way:
More on how to insert ruby code in haml: Inserting ruby
And, just so there are no doubts about passing ids and classes to
link_to, here is an example from the docs: