1

I have the following piece of haml code

%dt= 'Properties'
%dd{title: 'Properties'}
  - config[:Properties].each do |key, values|
    %p
      %em
        %b= t('.Key')
      = key
      %em
        %b= t('.Value')
      = values

here rather than making it key "..." value " ..." for each and every key/value pair. I would like to make the key and value as a list header . Such that

Key  value 

...   ....
...   ....
...   ....

Anyone have any suggestion on how i can achieve this ?

kauschan
  • 446
  • 2
  • 8
  • 21

1 Answers1

2

Did you meant a table with 2 columns? Listing all the possible key/value pair inside?

Here it is:

%table
  - config[:properties].each do |key, value|
    %tr
      %td= key
      %td= value

You can even add the theader and tbody tags if you want:

%table
  %thead
    %tr
      %th= 'Key'
      %td= 'Value'
  %tbody
    - config[:properties].each do |key, value|
      %tr
        %td= key
        %td= value
MrYoshiji
  • 54,334
  • 13
  • 124
  • 117