local p =
--creates a frame object that cannot access any of the parent's args--unless a table containing a list keys of not to inherit is providedfunction disinherit(frame, onlyTheseKeys) local parent = frame:getParent or frame local orphan = parent:newChild orphan.getParent = parent.getParent --returns nil orphan.args = if onlyTheseKeys then local family = for f = 1, 2 do for k, v in pairs(family[f] and family[f].args or) do orphan.args[k] = orphan.args[k] or v end end parent.args = mw.clone(orphan.args) setmetatable(orphan.args, nil) for _, k in ipairs(onlyTheseKeys) do rawset(orphan.args, k, nil) end end return orphan, parentend
function getSeparator(args, default) local br = tonumber(args.br) and ('
'):rep(args.br) or args.br local sep = args.sep or br or default return #sep > 0 and ' ' .. sep .. ' ' or sepend
function p.get(frame, arg, passArgs) local orphan, frame = disinherit(frame, passArgs and) local code = frame.args[arg or 1] or if code:match'UNIQ%-%-nowiki' then code = mw.text.unstripNoWiki(code) :gsub('<', '<') :gsub('>', '>') :gsub('"', '"') -- Replace `}%-` with `}-` because of some server quirk leading to -- =mw.text.unstripNoWiki(mw.getCurrentFrame:preprocess('}-')) -- outputting `}-` instead of `}-`, while it's ok with `} -` :gsub('}%-', '}-') -- The same with `-{` :gsub('%-{', '-