Module:mg-noun: Difference between revisions
No edit summary |
No edit summary |
||
| (4 intermediate revisions by the same user not shown) | |||
| Line 37: | Line 37: | ||
local word = NAMESPACE == "Template" and "mazer" or parent_args["word"] or PAGENAME | local word = NAMESPACE == "Template" and "mazer" or parent_args["word"] or PAGENAME | ||
local args = {} | local args = {} | ||
local decl_type = parent_args[2] or parent_args["decl"] or detect_decl(word) | local decl_type = NAMESPACE == "Template" and "r" or parent_args[2] or parent_args["decl"] or detect_decl(word) | ||
if g ~= "m" and g ~= "f" and g ~= "?" then error("Unknown gender: it must be either ‘m’ or ‘f’") end | if g ~= "m" and g ~= "f" and g ~= "?" then error("Unknown gender: it must be either ‘m’ or ‘f’") end | ||
| Line 74: | Line 74: | ||
-- make the table | -- make the table | ||
return make_table(data) | return make_table(data, parent_args) | ||
end | end | ||
function make_table(data) | function make_table(data, args) | ||
local function show_form(form) | local function show_form(form) | ||
| Line 124: | Line 124: | ||
for _, case in ipairs(cases) do | for _, case in ipairs(cases) do | ||
local case_short = sub(case, 1, 2) | local case_short = sub(case, 1, 2) | ||
local form_s = args[case_short .. '_s'] and {args[case_short .. '_s']} or data.forms[case_short .. '_s'] or nil | |||
local form_p = args[case_short .. '_p'] and {args[case_short .. '_p']} or data.forms[case_short .. '_p'] or nil | |||
table.insert(ret, '|- \n! ' .. case .. '\n') | table.insert(ret, '|- \n! ' .. case .. '\n') | ||
table.insert(ret, '| ' .. link(show_form( | table.insert(ret, '| ' .. link(show_form(form_s)) .. '\n') | ||
if not data.nopl then | if not data.nopl then | ||
table.insert(ret, '| ' .. link(show_form( | table.insert(ret, '| ' .. link(show_form(form_p)) .. '\n') | ||
end | end | ||
end | end | ||