Module:TAMNAMS: Difference between revisions

Ganaram inukshuk (talk | contribs)
Lookup functions should all return nil if nothing can be found; this affects lookups for step ratios and step ratio ranges
Ganaram inukshuk (talk | contribs)
Added name/prefix/abbrev verifier functions, for use with templates that potentially require outside-of-tamnams names/prefixes/abbrevs
Line 279: Line 279:
return nil
return nil
end
end
end
--------------------------------------------------------------------------------
------------------------ TEMPLATE HELPER FUNCTIONS -----------------------------
--------------------------------------------------------------------------------
-- Verifier function that checks for a name that's already provided by TAMNAMS.
-- If there is one provided, use that. If there is none, use the name passed in.
-- If no name is provided or the string "NONE" is entered, use the scalesig.
function p.verify_name(input_mos, mos_name)
local mos_name = p.lookup_name(input_mos) or mos_name or mos.as_string(input_mos)
if mos_name == "NONE" or mos_name == "" then
mos_name = mos.as_string(input_mos)
end
return mos_name
end
-- Verifier function that checks for a prefix already provided by TAMNAMS.
-- If there is one provided, use that. If there is none, use the one passed in.
-- If no prefix is provided, defualt to "mos". If "NONE" is entered, return an
-- empty string.
function p.verify_prefix(input_mos, mos_prefix)
local mos_prefix = p.lookup_prefix(input_mos) or mos_prefix or "mos"
if mos_prefix == "NONE" or mos_prefix == "" then
mos_prefix = ""
end
return mos_prefix
end
-- Verifier function that checks for an abbrev already provided by TAMNAMS.
-- If there is one provided, use that. If there is none, use the one passed in.
-- If no abbrev is provided, defualt to "m". If "NONE" is entered, return an
-- empty string.
function p.verify_abbrev(input_mos, mos_abbrev)
local mos_abbrev = p.lookup_abbrev(input_mos) or mos_abbrev or "m"
if mos_abbrev == "NONE" or mos_abbrev == "" then
mos_abbrev = ""
end
return mos_abbrev
end
end