Module:TableGenerator: Difference between revisions

Sur (talk | contribs)
m better examples
Sur (talk | contribs)
mNo edit summary
Line 57: Line 57:
     -- Initialize the HTML table structure
     -- Initialize the HTML table structure
     local result = ''
     local result = ''
 
   
     if not onlyBody then
     if not onlyBody then
         result = result .. '<table class="wikitable">\n'
         result = result .. '<table class="wikitable">\n'
Line 68: Line 68:
             -- If it's the start of a new row
             -- If it's the start of a new row
             if count % cols == 0 then
             if count % cols == 0 then
                if count > 0 then
                    result = result .. '  </tr>\n'
                end
                 result = result .. '  <tr>\n'
                 result = result .. '  <tr>\n'
             end
             end
Line 74: Line 77:
             result = result .. '    <td>' .. value .. '</td>\n'
             result = result .. '    <td>' .. value .. '</td>\n'
             count = count + 1
             count = count + 1
            -- Close the row if we reached the end of a column set
            if count % cols == 0 then
                result = result .. '  </tr>\n'
            end
         end
         end
     end
     end
      
      
     -- Close any unfilled row
     -- Close the last row if necessary
     if count % cols ~= 0 then
     if count % cols ~= 0 then
         result = result .. '  </tr>\n'
         result = result .. '  </tr>\n'