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