Module:Contentious topics/make link
Jump to navigation
Jump to search
| This module is rated as beta. It is considered ready for widespread use, but as it is still relatively new, it should be applied with some caution to ensure results are as expected. |
Given a contentious topic code, this module outputs a link to a contentious topic subpage formatted to remove the "Wikipedia:Contentious topics/" prefix from the display.
Usage
[edit source]{{#invoke:Contentious topics/make link|makeTopicLink|<contentious topic code>}}
{{#invoke:Contentious topics/make link|makeTopicLink|blp}}→ Biographies of Living Persons{{#invoke:Contentious topics/make link|makeTopicLink|sasg}}→ South Asia{{#invoke:Contentious topics/make link|makeTopicLink|does not exist}}→ Error!does not existis not a valid contentious topic code{{#invoke:Contentious topics/make link|makeTopicLink}}→ Error! No contentious topic code given
From a Lua module, use code like:
require('Module:Contentious topics/make link')._makeTopicLink(<code>)
local p = {}
function p.makeTopicLink(frame)
-- call from a template
args = require('Module:Arguments').getArgs(frame)
return p._makeTopicLink(args['code'] or args[1])
end
function p._makeTopicLink(code)
-- call from a module
local topicSubpage = mw.getCurrentFrame():expandTemplate{
title = "Contentious topics/list",
args = { ['topic-subpage'] = code }
}
if code == nil then
return '<span class="error">Error! No contentious topic code given</span>'
elseif topicSubpage == '' then
return '<span class="error">Error! <code>' .. code .. '</code> is not a valid contentious topic code</span>'
end
return '[[' .. topicSubpage ..'|'
.. mw.ustring.gsub(topicSubpage, 'Wikipedia:Contentious topics/', '')
.. ']]'
end
return p