Module:Sandbox/isaacl/ExpandPageAbbreviation
Appearance
-- For unit tests, see [[Module:Sandbox/isaacl/ExpandPageAbbreviation/tests]]
local moduleSelf = {
mw = require("Module:Mw"),
outputForAbbr = { },
}
-- if mw.loadData() not supported, use require() instead
if moduleSelf.mw.loadData then
moduleSelf.phraseForAbbr = moduleSelf.mw.loadData('Module:Sandbox/isaacl/ExpandPageAbbreviation/data')
else
moduleSelf.phraseForAbbr = require('Module:Sandbox/isaacl/ExpandPageAbbreviation/data')
end
function moduleSelf._expand(abbr)
if moduleSelf.outputForAbbr[abbr] ~= nil then
return moduleSelf.outputForAbbr[abbr]
else
if moduleSelf.phraseForAbbr[abbr] == nil then
moduleSelf.outputForAbbr[abbr] = string.format("[[%s]]", abbr)
else
moduleSelf.outputForAbbr[abbr] = string.format("[[%s|%s]] (%s)",
abbr, moduleSelf.phraseForAbbr[abbr], abbr)
end
return moduleSelf.outputForAbbr[abbr]
end
end -- function _expand()
function moduleSelf.expand(frame)
local abbr = frame.args[1]
return moduleSelf._expand(abbr)
end
return moduleSelf