There were times when I wanted to index the class name during application development, and I was confused about how to write it, so please refer to it if there is a similar person.
First, the basic class name id name is written starting with "." And "#".
#name of the class
.item_name
%p.item_name
#ID name
#item_name
%p#item_name
And this time I stumbled upon how to write using variable names in each statement. It was applied in the following writing style!
[email protected]_with_index do |item, i|
%div{class: "#{item.name}"}
%p{class: "item_name_#{i}"}
Enclose the class name in {} and it will be applied! It is applied in the same way even if it is not a each statement
%div{class: @item.name}