Documentation for this module may be created at Module:Sandbox/Johnuniq/temp/doc
-- Investigate frame and getParent assuming called from an invoke.
local function pre_block(text)
-- Pre tags returned by a module do not act like wikitext <pre>...</pre>.
return '<pre>\n' ..
mw.text.nowiki(text) ..
(text:sub(-1) == '\n' and '' or '\n') ..
'</pre>\n'
end
local function show(results, frame, title)
if results[1] then
table.insert(results, '')
end
table.insert(results, title)
if frame == nil then
table.insert(results, 'nil')
return
end
table.insert(results, 'title: ' .. frame:getTitle())
table.insert(results, 'args:')
for k, v in pairs(frame.args) do
table.insert(results, ' ' .. k .. ' = ' .. (v or '(empty)'))
end
end
local function main(frame)
local parent = frame:getParent()
local grandparent = parent:getParent() -- always nil
local results = {}
show(results, frame, 'frame')
show(results, parent, 'parent')
show(results, grandparent, 'grandparent')
return pre_block(table.concat(results, '\n'))
end
return { main = main }
