Module:Testcase table
Appearance
--
-- This module will implement {{Testcase table}}
--
local p = {}
function p.testcase(frame)
local args = frame:getParent().args
local basepagename = mw.ustring.gsub(mw.title.getCurrentTitle().text, '/.*$', '');
local tableclass = ''
local template1 = args['_template1'] or args['_template'] or (basepagename)
local template2 = args['_template2'] or (template1 .. '/sandbox')
local heading1 = args['_heading1'] or '{{[[Template:' .. template1 .. '|' .. template1 ..']]}}'
local heading2 = args['_heading2'] or '{{[[Template:' .. template2 .. '|' .. template2 ..']]}}'
local heading0 = ''
local rowheader = ''
local caption = args['_caption'] or 'Side by side comparison'
local t = {}
if( args['_rowheader'] ) then
rowheader = '<td scope=row>' .. args['_rowheader'] .. '</td>'
if( args['_heading0'] ) then
heading0 = '<th>' .. args['_heading0'] .. '</th>'
end
end
if( args['_class'] ) then
tableclass = ' class="' .. args['_class'] .. '"'
end
for k, v in pairs(args) do
t[k] = v
end
return mw.ustring.format( [==[
<table%s><caption>%s</caption>
<tr>%s<th style="width:50%%">%s</th><th style="width:50%%">%s</th></tr>
<tr style="vertical-align:top">%s<td>
%s</td><td>
%s</td></tr></table>]==],
tableclass, caption,
heading0, heading1, heading2, rowheader,
frame:expandTemplate{ title = template1, args = t },
frame:expandTemplate{ title = template2, args = t }
)
end
return p