Module:Delink: Difference between revisions
From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
Content added Content deleted
(since mw.ustring is 30x slower than string, only use it when necessary) |
(use Module:Arguments) |
||
Line 2: | Line 2: | ||
local p = {} |
local p = {} |
||
local getArgs |
|||
local function delinkReversePipeTrick(s) |
local function delinkReversePipeTrick(s) |
||
Line 168: | Line 170: | ||
function p.delink(frame) |
function p.delink(frame) |
||
if not getArgs then |
|||
local args |
|||
getArgs = require('Module:Arguments').getArgs |
|||
if frame == mw.getCurrentFrame() then |
|||
-- We're being called via #invoke. If the invoking template passed any args, use |
|||
-- them. Otherwise, use the args that were passed into the template. |
|||
args = frame:getParent().args |
|||
for k, v in pairs(frame.args) do |
|||
args = frame.args |
|||
break |
|||
end |
|||
else |
|||
-- We're being called from another module or from the debug console, so assume |
|||
-- the args are passed in directly. |
|||
args = frame |
|||
end |
end |
||
return p._delink( |
return p._delink(getArgs(frame, {wrappers = 'Template:Delink'})) |
||
end |
end |
||