Module:Unit: Difference between revisions
From Eco - English Wiki
[unchecked revision] | [unchecked revision] |
mNo edit summary |
mNo edit summary |
||
Line 18: | Line 18: | ||
if unitData then | if unitData then | ||
return HTMLUtils.tagAbbr(unitData | return HTMLUtils.tagAbbr(unitData[1], unitData[2]) | ||
else | else | ||
return string.format("ERROR: Abbreviation for unit \"%s\" not yet implemented!", abbrKey) | return string.format("ERROR: Abbreviation for unit \"%s\" not yet implemented!", abbrKey) |
Revision as of 15:22, 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 string.format("ERROR: Abbreviation for unit \"%s\" not yet implemented!", abbrKey)
end
else
return string.format("ERROR: Invalid abbreviation \"%s\"!", abbrKey)
end
else
return "ERROR: No unit symbol given!"
end
end
return p