Wiki/Module:Footnote: Difference between revisions
No edit summary |
m Protected "Wiki/Module:Footnote" ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)) |
(No difference)
| |
Latest revision as of 05:09, 27 October 2025
local p = {}
local function getArgsFromFrame(frame) -- Prefer parent args (when module is called from a template), otherwise use frame.args local parent = nil if frame.getParent then parent = frame:getParent() end if parent and parent.args then return parent.args end -- fallback to frame.args (when module is invoked directly with parameters) if frame.args then return frame.args end -- ultimate fallback: empty table return {} end
local function makeRef(args) local content = args[1] or -- some templates pass parameters as strings or tables, handle both local name = args.name or args["name"] or local group = args.group or args["group"] or local ref = args.ref or args["ref"] or local tag = 'ref'
local out = '<' .. tag if name ~= then out = out .. ' name="' .. mw.text.escape(name) .. '"' end if group ~= then out = out .. ' group="' .. mw.text.escape(group) .. '"' end out = out .. '>'
if ref ~= then out = out .. ref elseif content ~= then out = out .. content end
out = out .. '</' .. tag .. '>' return out end
function p.efn(frame) local args = getArgsFromFrame(frame) return makeRef(args) end
function p.refn(frame) local args = getArgsFromFrame(frame) return makeRef(args) end
function p.notelist(frame) local args = getArgsFromFrame(frame) local group = args.group or args["group"] or 'note' local refs = args.refs or args["refs"] or return '' end
return p