Module:Sandbox/Ahecht: Difference between revisions

Content deleted Content added
test
test
 
(54 intermediate revisions by the same user not shown)
Line 1:
local p = {}
 
local dots = ...
 
function p.main(frame)
local output = ''{}
output[1] = output .. 'frame: ' .. type(frame) .. ' '
if frame[1] then
output[2] = output .. frame[1] end
else
output = output .. '\<br />frame.args: ' .. type(frame.args) .. ' '
output[2] = ''
if frame.args[1] then output = output .. frame.args[1] end
end
output = output .. '<br />frame:getParent().args ' .. type(frame:getParent().args) .. ' '
ifoutput[3] = '<br />frame:getParent().args: then output = output' .. type(frame:getParent(.args) .args[1]. ' end'
if frame.args[1] then
return output
output[4] = frame.args[1]
else
output[4] = ''
end
output[5] = output .. '\<br />frame:getParent().args: ' .. type(frame:getParent().args) .. ' '
if frame:getParent().args[1] then
output[6] = frame:getParent().args[1]
else
output[6] = ''
end
if frame.args['test'] == 0 then
output[7] = '<br />0 the number'
elseif frame.args['test'] == '0' then
output[7] = '<br />0 the character'
else
output[7] = ''
end
local thisframe = mw.getCurrentFrame()
if thisframe then
output[8] = "<br />mw.getCurrentFrame():getTitle(): "
output[9] = thisframe:getTitle()
thisframe = thisframe:getParent()
if thisframe then
output[10] = "<br />mw.getCurrentFrame():getParent():getTitle(): "
output[11] = thisframe:getTitle()
thisframe = thisframe:getParent()
if thisframe then
output[12] = "<br />mw.getCurrentFrame():getParent():getParent():getTitle(): "
output[13] = thisframe:getTitle()
end
end
end
return table.concat(output)
end
 
function p.isnumeric(frame)
local s = frame.args[1] or frame:getParent().args[1]
local boolean = (frame.args.boolean or frame:getParent().args.boolean) == 'true'
if type(s) == 'string' and mw.getContentLanguage():parseFormattedNumber( s ) then
return boolean and 1 or s
end
return boolean and 0 or ''
end
 
function error(frame, key)
return "Error! Missing function " .. key
end
 
metatable = {['__index'] = error}
 
setmetatable(p, metatable)
 
function p.dots()
return outputdots
end
 
function p.prefix(frame)
local args = {}
for k,v in pairs(frame.args) do
if k ~= '_prefix' and k ~= '_template' then
table.insert(args, '| ' .. (frame.args['_prefix'] or '') .. k .. " = " .. v)
end
end
return table.concat(args, '\n')
end
 
return setmetatable(p, {__index =
function(_, key) -- this anonymous function called as function(TABLE, KEY)
return function (frame) return error (frame, key) end; -- which in turn returns a function that calls cite() with the KEY name
end
})