Module:Module link
Jump to navigation
Jump to search

This module depends on the following module(s):
* Module:Arguments

This module depends on the following module(s):
* Module:Arguments
Implements {{Module link}}
Usage[edit source]
{{#invoke:Module link|main|[module:name]}}
-- Implements {{ml}}
local ml = {}
local getArgs = require('Module:Arguments').getArgs
local format = mw.ustring.format
local title = mw.title.getCurrentTitle()
local function err(msg)
if title.nsText == "Module" then
help = '' .. '([[Module:Module link#Errors|help]])'
else
help = '' .. '([[Template:Module link#Errors|help]])'
end
return format('<strong class="error">Error: %s %s</strong>', msg, help)
end
function ml.main(frame)
args = getArgs(frame)
return ml._main(args)
end
function ml._main(args)
if args[1] or args.link then
name = args[1] or args.link
elseif args[1] == nil then
return err("parameter and value or module title required")
end
sandbox = mw.title.new(name .. '/sandbox')
if sandbox and sandbox.exists then
return format("[[:%s]] ([[:%s|sandbox]])", name, sandbox.fullText)
elseif args[1] == '' then
return err('no module name found')
else return format("[[:%s]]", name)
end
end
return ml