1

My question is kind of a general ruby question, but I'm using HAML so I'll ask it in that context.

I'm using twitter bootstrap and I want to iterate over a list to populate a popover's content

I have:

    %div 
      =link_to link_name, link, ..., "data-content" => <my_content_here>

and I want to put something like the following into the data content. I've tried partials, but can't seem to get anything to work

    %div
      f.item.each do |t|
        .myclass=t

1 Answers1

2

HAML

%div
 - f.item.each do |t| 
   = link_to link_name, link, ..., data: {content: your_content}, class: t

You'll benefit from reading up on the HAML docs

You basically just need to indent for each code bock; your div being a block & your . each loop being a block

The main thing you need to remember is that = is equal to <%= | - is equal to <%

Richard Peck
  • 76,116
  • 9
  • 93
  • 147