html.erb (how to specify both id and class) and combining haml code

176 views Asked by At

I have a line of code

<li class="m-bottom-20">

and

<li id="faq_<%= faq.id %>">

How do I combine these 2 lines to specify both class and id? Also, I have another question concerning combining haml code. I have this line of haml code already

%li.m-bottom-20

but I need to replace it with this line

= content_tag_for :li, faq do

But still keep the formatting for li.

These 2 questions are actually referring to the same 2 lines of code, one in html.erb and one in haml.

2

There are 2 answers

0
Mandeep On BEST ANSWER

You can specify class and ids to li like this:

%li.m-bottom-20{id: "faq_#{faq.id}"}

or

= content_tag :li, class: "m-bottom-20", id: "faq_#{faq.id}" do
  "Some content"
0
nesiseka On

Something like this should work:

%li.m-bottom-20{id: "faq_#{faq.id}"}
  = content_tag_for :li, faq do