Module:Sandbox/Ahecht: Difference between revisions

Content deleted Content added
default to ___location 1
test
 
(22 intermediate revisions by the same user not shown)
Line 1:
local p = {}
 
local argsdots = {[0]={}}...
 
function p.main(frame)
local output = {}
Line 8 ⟶ 11:
output[2] = ''
end
output[3] = '\<br />frame.args: ' .. type(frame.args) .. ' '
if frame.args[1] then
output[4] = frame.args[1]
Line 28 ⟶ 31:
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.infoboxattractionisnumeric(frame)
forlocal k,vs in= frame.args[1] or pairs(frame:getParent().args) do[1]
local output = {"{{Infobox attraction/section/sandbox"}
local boolean = (frame.args.boolean or frame:getParent().args.boolean) == 'true'
local args = {[0]={}}
if type(s) == 'string' and mw.getContentLanguage():parseFormattedNumber( s ) then
for k,v in pairs(frame:getParent().args) do
return boolean and 1 or s
local val = mw.text.trim(v)
if val or "" ~= "" then
-- val exists and isn't blank
local loc = tonumber(mw.ustring.sub(k,-1))
if (loc) and (loc > 0) and (loc <= 10)
and (not mw.ustring.match(k, "^location_%d+$"))
and (not mw.ustring.match(k, "^custom_")) then
-- last character is a number 1-10, and it's not "location_#" or "custom_"
if not args[loc] then args[loc] = {} end
-- strip "location_" and number from key
local key = mw.ustring.gsub(mw.ustring.gsub(k, "_?%d+$", ""), "^location_", "")
args[loc][key] = val
elseif (not loc) and (mw.ustring.match(k, "^location_%D")) then
-- default to ___location 1
if (not args[1]) then args[1] = {} end
-- strip "location_" from key
local key = mw.ustring.gsub(k, "^location_", "")
args[1][key] = val
else
args[0][k] = val
end
end
end
return boolean and 0 or ''
for k, v in pairs(args[0]) do
end
table.insert(output, "| " .. k .. " = " .. v)
 
end
function error(frame, key)
for i, a in ipairs(args) do
return "Error! Missing function " .. key
if not args[0]["location_" .. i] then
end
-- ___location subtemplate isn't defined
 
table.insert(output, "| location_" .. i .. " = {{Infobox attraction/section/sandbox|child=yes")
metatable = {['__index'] = error}
for k, v in pairs(a) do
 
table.insert(output, "| " .. k .. " = " .. v)
setmetatable(p, metatable)
end
 
table.insert(output,"}}")
function p.dots()
return dots
end
 
function p.prefix(frame)
local args = {}
for k, v in pairs(frame.args[0]) do
if k ~= '_prefix' and k ~= '_template' then
table.insert(outputargs, "'| "' .. (frame.args['_prefix'] or '') .. k .. " = " .. v)
end
end
return table.insertconcat(outputargs, "}}"'\n')
return table.concat(output, "\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
})