Difference between revisions of "Module:Good article topics"
Jump to navigation
Jump to search
blackwiki>Mr. Stradivarius (add default value for the topic variable) |
m (4 revisions imported) |
||
| (2 intermediate revisions by one other user not shown) | |||
| Line 4: | Line 4: | ||
function p.main(frame) | function p.main(frame) | ||
| − | local topic = frame:getParent().args[1] | + | local topic = frame:getParent().args[1] |
| + | if not topic then | ||
| + | return '' | ||
| + | end | ||
topic = topic:match('^%s*(.-)%s*$') -- Trim whitespace | topic = topic:match('^%s*(.-)%s*$') -- Trim whitespace | ||
local ret | local ret | ||
Latest revision as of 17:04, 26 September 2020
| This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing. |
This module implements Template:GA/Topic; please see the template page for documentation.
The topic name data is stored at Module:Good article topics/data.
-- This module implements {{GA/Topic}}.
local p = {}
function p.main(frame)
local topic = frame:getParent().args[1]
if not topic then
return ''
end
topic = topic:match('^%s*(.-)%s*$') -- Trim whitespace
local ret
if topic ~= '' then
ret = p._main(topic)
end
ret = ret or ''
return ret
end
function p._main(topic)
topic = topic:lower()
local data = mw.loadData('Module:Good article topics/data')
return data[topic]
end
return p