Module:Testcase table: Difference between revisions

Content deleted Content added
try some performance tweaks (although the old version looked pretty fast too)
partial undo - you can't pass the arguments directly to the other table directly from the frame object, you need to use pairs()
Line 6:
function p.testcase(frame)
local args = frame:getParent().args
local basepagename = mw.ustring.gsub(mw.title.getCurrentTitle().rootTexttext, '/.*$', '');
args['_template1']local template1 = args['_template1'] or (basepagename)
args['_template2']local template2 = args['_template2'] or (basepagename .. '/sandbox')
args['_heading1']local heading1 = args['_heading1'] or '{{[[Template:' .. args['_template1']template1 .. '|' .. args['_template1']template1 ..']]}}'
args['_heading2']local heading2 = args['_heading2'] or '{{[[Template:' .. args['_template2']template2 .. '|' .. args['_template2']template2 ..']]}}'
args['_caption']local caption = args['_caption'] or 'Side by side comparison'
local t = {}
for k, v in pairs(args) do
local res1 = frame:expandTemplate{ title = args['_template1'], args = args }
t[k] = v
local res2 = frame:expandTemplate{ title = args['_template2'], args = args }
end
local res1 = frame:expandTemplate{ title = args['_template1']template1, args = argst }
local res2 = frame:expandTemplate{ title = args['_template2']template2, args = argst }
return mw.ustring.format( [==[
Line 22 ⟶ 27:
%s</td><td>
%s</td></tr></table>]==],
args['_caption']caption,
args['_heading1']heading1, args['_heading2']heading2,
res1,
res2