Module:Testcase table: Difference between revisions

Content deleted Content added
partial undo - you can't pass the arguments directly to the other table directly from the frame object, you need to use pairs()
Apparently that doesn't work
Tag: New redirect
 
(22 intermediate revisions by 4 users not shown)
Line 1:
return require [[Module:Template test case]]
--
-- 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 template1 = args['_template1'] or (basepagename)
local template2 = args['_template2'] or (basepagename .. '/sandbox')
local heading1 = args['_heading1'] or '{{[[Template:' .. template1 .. '|' .. template1 ..']]}}'
local heading2 = args['_heading2'] or '{{[[Template:' .. template2 .. '|' .. template2 ..']]}}'
local caption = args['_caption'] or 'Side by side comparison'
local t = {}
for k, v in pairs(args) do
t[k] = v
end
local res1 = frame:expandTemplate{ title = template1, args = t }
local res2 = frame:expandTemplate{ title = template2, args = t }
return mw.ustring.format( [==[
<table><caption>%s</caption>
<tr><th style="width:50%%">%s</th><th style="width:50%%">%s</tr>
<tr style="vertical-align:top"><td>
%s</td><td>
%s</td></tr></table>]==],
caption,
heading1, heading2,
res1,
res2
)
end
 
return p