Module:Flag and Module:Flag/sandbox: Difference between pages
Appearance
(Difference between pages)
Content deleted Content added
simplify |
add metatable |
||
Line 136: | Line 136: | ||
p['IOC athlete'] = p.IOCathlete |
p['IOC athlete'] = p.IOCathlete |
||
local function index (_, key) -- This function gets called by the metatable as index(table, key) |
|||
function ( |
return function (frame) return _main(frame, 'Flag', 'unc', key) end -- Interpret it as {{flag|key}} as pass to _main() |
||
⚫ | |||
return function (frame) return _main(frame, 'Flag', 'unc', key) end -- which interprets the module call as {{flag|KEY}} and passes it to _main() |
|||
⚫ | |||
local metatable = {['__index'] = index} -- Set __index, which is returned if table[key] is nil, to the index function |
|||
}) |
|||
setmetatable (p, metatable) -- Assign the metatable to the returned table |
|||
return p |