Module:Yesno: Difference between revisions
Jump to navigation
Jump to search
m>Ori Livneh Add inline comments |
m>Mr. Stradivarius get arguments from the parent frame if the current frame doesn't have any |
||
Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
function p.yesno( frame ) | function p.yesno(frame) | ||
-- defaults | -- defaults | ||
Line 12: | Line 12: | ||
-- Allow arguments to override defaults. | -- Allow arguments to override defaults. | ||
-- 'any' tracks the presence of any arguments at all. | -- 'any' tracks the presence of any arguments at all. | ||
local args = frame.args | |||
local any = false | local any = false | ||
for k,v in pairs( | for k,v in pairs(args) do | ||
any = true | any = true | ||
retvals[k] = v | retvals[k] = v | ||
end | end | ||
-- If there are no arguments, try and get them from the parent frame. | |||
if any == false then | |||
local pframe = frame:getParent() | |||
args = pframe.args | |||
for k,v in pairs(args) do | |||
any = true | |||
retvals[k] = v | |||
end | |||
end | |||
val = | val = args[1] | ||
-- According to the template docs, the input should be considered nil | -- According to the template docs, the input should be considered nil |