Module:Unit: Difference between revisions
From Eco - English Wiki
[unchecked revision] | [unchecked revision] |
mNo edit summary |
mNo edit summary |
||
Line 20: | Line 20: | ||
return HTMLUtils.tagAbbr(unitData[1], unitData[2]) | return HTMLUtils.tagAbbr(unitData[1], unitData[2]) | ||
else | else | ||
return | return abbrKey | ||
end | end | ||
else | else |
Revision as of 15:28, 23 February 2022
Template:Doc/start Template:Template backend Unit definitions are loaded from Module:Unit/data. Template:Doc/end
local p = {}
local Utils = require("Module:Utils")
local UnitsData = mw.loadData("Module:Sandbox/Demian/Unit/data")
local HTMLUtils = require("Module:UtilsHTML")
function p.main(frame)
local args = Utils.normaliseArgs(frame)
if args[1] then
local abbrKey = tostring(args[1])
if abbrKey then
local unitData = UnitsData["caseSensitiveUnits"][abbrKey]
if not unitData then
unitData = UnitsData["caseInsensitiveUnits"][abbrKey]
end
if unitData then
return HTMLUtils.tagAbbr(unitData[1], unitData[2])
else
return abbrKey
end
else
return string.format("ERROR: Invalid abbreviation \"%s\"!", abbrKey)
end
else
return "ERROR: No unit symbol given!"
end
end
return p