Module:User:Benwing2/definition/templates
Jump to navigation
Jump to search
- This module sandbox lacks a documentation subpage. You may create it.
- Useful links: root page • root page’s subpages • links • transclusions • testcases • user page • user talk page • userspace
This is a private module sandbox of Benwing2, for their own experimentation. Items in this module may be added and removed at Benwing2's discretion; do not rely on this module's stability.
local export = {}
local m_definition = require("Module:User:Benwing2/definition")
-- Used for [[Template:&lit]].
function export.and_lit_t(frame)
local parent_args = frame.getParent and frame:getParent().args or frame
local compat = parent_args["lang"]
local offset = compat and 0 or 1
local params = {
[compat and "lang" or 1] = {required = true, default = "und"},
[1 + offset] = {list = true, allow_holes = true},
["alt"] = {list = true, allow_holes = true, require_index = true},
["sc"] = {},
["qualifier"] = {},
["dot"] = {},
["nodot"] = {type = "boolean"},
}
local args = require("Module:parameters").process(parent_args, params)
local lang = args[compat and "lang" or 1]
lang = require("Module:languages").getByCode(lang) or m_languages.err(lang, 1)
local sc = args["sc"]
sc = (sc and (require("Module:scripts").getByCode(sc) or error("The script code \"" .. sc .. "\" is not valid.")) or nil)
-- Find the maximum index among any of the list parameters.
local maxmaxindex = 0
for k, v in pairs(params) do
if v.list and v.allow_holes and not v.alias_of and args[k].maxindex > maxmaxindex then
maxmaxindex = args[k].maxindex
end
end
local terms = {}
for i=1,maxmaxindex do
table.insert(terms, {
term = args[1 + offset][i],
alt = args["alt"][i],
lang = lang,
sc = sc
})
end
return m_definition.and_lit(terms, args["qualifier"], args["dot"], args["nodot"])
end
return export