Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7625673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:13:22+00:00 2026-05-31T05:13:22+00:00

I am trying to create an HTML table in HAML that has a first

  • 0

I am trying to create an HTML table in HAML that has a first column where each cell spans a dynamic number of rows based on the number of values in an Array which will be split across multiple cells in the second column. So for example, if Array.size == 2, then the first cell in the first column will have rowspan=2 and the second column will have Array[0] in the first row and Array[1] in the second row and the column 1 value will span both rows. The HAML code I wrote to do this is as follows:

- @array1.each do |item|
    %tr
    %td{:rowspan => "#{item.array.size}"}= time_tag(item.created_at)
    - item.array.each do |item|
      %td= "#{item.name}" 
      %tr

The issue I am having is that HAML automatically inserts one set of row tags after each loop through the second block which results in the second item.name ending up in the first column of the second row instead of in the second column of the second row. How can I fix my code to make the table work as I described it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T05:13:22+00:00Added an answer on May 31, 2026 at 5:13 am

    I don’t know if I understand you but I think it could work with the following code:

    %table
    - @products.each do |item|
      %tr
        %td{:rowspan => "#{item.array.size}"}= "#{item.name}"
        %td
          - item.array.each do |item2|
            %tr
              %td= "#{item2.name}"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create an HTML/CSS-based week calendar using CSS display:table-cell styling on the
I'm trying to create text in html, that once clicked, the the value of
I am trying to create some dynamic html out of some data from db.
I'm currently trying dynamically create an html table in PHP. Further, I want the
I'm trying to create Class Table Inheritance as in ( http://www.castleproject.org/activerecord/documentation/trunk/usersguide/typehierarchy.html ) So let's
I'm trying to create a page with a number of static html tables on
I'm trying to create a calendar in an HTML table design with CSS element
I'm trying to create a editable textbox with HTML/CSS/Javascript that looks and functions like
I'm trying to create an html table for order logs for customers. A customer
I'm trying to create an html table from database records. I want the table

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.