Module:Contentious topics/make link
Appearance
| 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. |
| Editing of this module by new or unregistered users is currently disabled. See the protection policy and protection log for more details. If you cannot edit this module and you wish to make a change, you can submit an edit request, discuss changes on the talk page, request unprotection, log in, or create an account. |
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
{{#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