Editing Module:Aligned table
From MINR.ORG WIKI
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 12: | Line 12: | ||
local colstyle = {} | local colstyle = {} | ||
local cols = tonumber(args['cols']) or 2 | local cols = tonumber(args['cols']) or 2 | ||
+ | local noblankrows = args['noblankrows'] or '' | ||
-- create the root table | -- create the root table | ||
Line 112: | Line 113: | ||
else | else | ||
row:css('vertical-align', 'top') | row:css('vertical-align', 'top') | ||
+ | end | ||
+ | -- skip blank rows, if feature is enabled | ||
+ | local showrow = 1 | ||
+ | if isnotempty(noblankrows) then | ||
+ | showrow = 0 | ||
+ | for i=1,cols do | ||
+ | if isnotempty(args[cols*(j - 1) + i] or '') then | ||
+ | showrow = 1 | ||
+ | break | ||
+ | end | ||
+ | end | ||
end | end | ||
-- loop over the cells in the row | -- loop over the cells in the row | ||
+ | if showrow then | ||
for i=1,cols do | for i=1,cols do | ||
local cell | local cell | ||
Line 130: | Line 143: | ||
elseif args['row' .. tostring(j) .. 'class'] then | elseif args['row' .. tostring(j) .. 'class'] then | ||
cell:addClass(args['row' .. tostring(j) .. 'class']) | cell:addClass(args['row' .. tostring(j) .. 'class']) | ||
− | |||
− | |||
− | |||
− | |||
end | end | ||
if colclass[i] ~= '' then | if colclass[i] ~= '' then | ||
Line 151: | Line 160: | ||
end | end | ||
end | end | ||
− | cell:wikitext(mw.ustring.gsub(args[cols*(j - 1) + i] or '', ' | + | cell:wikitext(mw.ustring.gsub(args[cols*(j - 1) + i] or '','%s*$', '')) |
+ | end | ||
end | end | ||
end | end |