Module:Marriage
Appearance
![]() | This module is rated as alpha. It is ready for third-party input, and may be used on a few pages to see if problems arise, but should be watched. Suggestions for new features or changes in their input and output mechanisms are welcome. |
Usage
{{#invoke:Marriage|function_name}}
--
--
-- ! This module is currently Pre-Alpha and not ready for testing.
--
--
-- This module provides consistent formatting for common information included in
-- the spouse parameter of an Infobox_person.
-- It is intended to be used by Template:Marriage and not invoked directly within pages.
local getArgs = require('Module:Arguments').getArgs
local p = {}
local reason_types = {
-- ["variant"] = {"variants","variants","variants"},
["died"] = {"d", "d.", "died"},
["divorced"] = {"div", "div.", "divorce", "divorced"},
["separated"] = { "sep", "sep.", "separate", "separated" },
["annuled"] = { "ann", "ann.", "annulment", "annulled" },
["{{error-small|'reason is deprecated; use 'died' instead}}"] = { "she d.", "her d.", "she died", "her death" }, -- {{#ifeq:{{#property:P21}}|male|died|{{main other|[[Category:Marriage template errors|X{{PAGENAME}}]]}}{{error-small|"{{lc:{{{end|{{{reason|}}}}}}}}" is deprecated; use "died" instead}}}}
["{{error-small|'reason is deprecated; use 'died' instead}}"] = { "he d.", "his d.", "he died", "his death" }, -- {{#ifeq:{{#property:P21}}|female|died|{{main other|[[Category:Marriage template errors|X{{PAGENAME}}]]}}{{error-small|"{{lc:{{{end|{{{reason|}}}}}}}}" is deprecated; use "died" instead}}}}
["{{error-small|invalid reason}}"] = { "w", "w.", "wid", "wid.", "widow", "widowed" } -- {{main other|[[Category:Marriage template errors|W{{PAGENAME}}]]}}{{error-small|invalid reason }}
}
function contains(list, x)
for _, v in ipairs(list) do
if v == x then
return true
end
end
return false
end
function p.reasonFormatter(frame)
local args = getArgs(frame, {trim = true})
return p._reasonFormatter(args)
end
function p._reasonFormatter(args)
local reason_arg = args["end"]
local reason_arg_lower = string.lower(reason_arg)
local reason_result = "default"
for variant, variants in pairs(reason_types) do
if contains(variants, reason_arg_lower) then
reason_result = variant
else
reason_result = reason_arg
end
end
return reason_result
end
function p.main(frame)
local args = getArgs(frame)
return p._main(args)
end
function p._main(args)
-- Main module code will end up here.
return "Nothing to see here."
end
return p