Module:TableGenerator: Difference between revisions

Sur (talk | contribs)
m Undo revision 5125 by Sur (talk)
Tag: Undo
Sur (talk | contribs)
m color slightly darker
Line 2: Line 2:


--<table class="wikitable">
--<table class="wikitable">
--{{#invoke: TableGenerator | generateHtmlTable | cols=3 | onlyBody=true | Item 1 | Item 2 | Item 3 | Item 4 | Item 5 }}
--{{#invoke: TableGenerator | generateHtmlTable | cols=3 | onlyBody=true | cell_values=Item 1, Item 20, Item 3, Item 40, Item 5 }}
--</table>
--</table>


--creates
-- Creates:
 
-- Item 1, Item 20, Item 3
--Item 1, Item 2, Item 3
-- Item 40, Item 5
--Item 4, Item 5
function p.generateHtmlTable(frame)
function p.generateHtmlTable(frame)
     -- Get the arguments passed to the template
     -- Get the arguments passed to the template
Line 39: Line 38:
         end
         end


         -- Add the value as a table cell
        -- If the value contains a " 0 " then it will be colored slightly darker
         result = result .. '    <td>' .. value .. '</td>\n'
        local class = ''
        if value:find(" 0") and not value:find(" 0.") then
            class = ' class="darker"'
        end
 
         -- Add the value as a table cell with the appropriate class
         result = result .. '    <td' .. class .. '>' .. value .. '</td>\n'
         count = count + 1
         count = count + 1
     end
     end