Module:TableGenerator: Difference between revisionsGive feedback
Jump to navigation
Jump to search
Tag: Undo |
m color slightly darker |
||
| Line 2: | Line 2: | ||
--<table class="wikitable"> | --<table class="wikitable"> | ||
--{{#invoke: TableGenerator | generateHtmlTable | cols=3 | onlyBody=true | Item 1 | --{{#invoke: TableGenerator | generateHtmlTable | cols=3 | onlyBody=true | cell_values=Item 1, Item 20, Item 3, Item 40, Item 5 }} | ||
--</table> | --</table> | ||
-- | -- Creates: | ||
-- Item 1, Item 20, Item 3 | |||
--Item 1, Item | -- Item 40, Item 5 | ||
--Item | |||
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 | ||