Editing Module:Demo

From MINR.ORG WIKI

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 4: Line 4:
 
--unless a table containing a list keys of not to inherit is provided
 
--unless a table containing a list keys of not to inherit is provided
 
function disinherit(frame, onlyTheseKeys)
 
function disinherit(frame, onlyTheseKeys)
local parent = frame:getParent() or frame
+
local orphan, parent, args = frame:newChild{}, frame:getParent(), {}
local orphan = parent:newChild{}
+
orphan.getParent = (parent or frame).getParent --returns nil
orphan.getParent = parent.getParent --returns nil
+
--setmetatable(orphan.args, {index = args})
orphan.args = {}
+
--if 1 then return orphan, frame end
 
if onlyTheseKeys then
 
if onlyTheseKeys then
local family = {parent, frame}
+
for _, f in ipairs(parent and {parent.args, frame.args} or {frame.args})do
for f = 1, 2 do
+
for k, v in pairs(f) do
for k, v in pairs(family[f] and family[f].args or {}) do
+
args[k] = args[k] or v
orphan.args[k] = orphan.args[k] or v
 
 
end
 
end
 
end
 
end
parent.args = mw.clone(orphan.args)
 
setmetatable(orphan.args, nil)
 
 
for _, k in ipairs(onlyTheseKeys) do
 
for _, k in ipairs(onlyTheseKeys) do
rawset(orphan.args, k, nil)
+
args[k] = nil
 
end
 
end
 +
orphan.args = args
 
end
 
end
return orphan, parent
+
return orphan, frame
 
end
 
end
  
Line 68: Line 66:
 
'demo_kill_categories'
 
'demo_kill_categories'
 
})
 
})
 +
--if 1 then return mw.dumpObject(orphan.args) end
 
local template = frame.args.demo_template and 'Template:'..frame.args.demo_template
 
local template = frame.args.demo_template and 'Template:'..frame.args.demo_template
 
local demoFunc = frame.args.demo_module_func or 'main\n'
 
local demoFunc = frame.args.demo_module_func or 'main\n'

Please note that all contributions to MINR.ORG WIKI may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see MINR.ORG WIKI:Copyrights for details). Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)