Module:User:Jberkel/usex/templates
Jump to navigation
Jump to search
- The following documentation is located at Module:User:Jberkel/usex/templates/documentation. [edit]
- Useful links: root page • root page’s subpages • links • transclusions • testcases • user page • user talk page • userspace
This module is used by {{ux}}
to format the usage example for a definition line.
It delegates the actual work to Module:usex.
Exported functions
[edit]usex_t
[edit]{{#invoke:usex/templates|usex_t}}
Format a usage example. See {{ux}}
for more.
local m_usex = require("Module:User:Jberkel/usex")
local export = {}
function export.usex_t(frame)
local params = {
[1] = {required = true},
[2] = {},
[3] = {},
["inline"] = {type = "boolean"},
["noenum"] = {type = "boolean"},
["ref"] = {},
["lit"] = {},
["sc"] = {},
["t"] = {alias_of = 3},
["translation"] = {alias_of = 3},
["tr"] = {},
["transliteration"] = {alias_of = "tr"},
["qualifier"] = { list = true }
}
local quote = (frame.args["quote"] or "") ~= ""
local compat = (frame.args["compat"] or "") ~= ""
if compat then
params["lang"] = {required = true}
params["t"].alias_of = 2
params["translation"].alias_of = 2
table.remove(params, 1)
end
local args = require("Module:parameters").process(frame:getParent().args, params)
local lang = args[compat and "lang" or 1] or "und"
local sc = args["sc"]
lang = require("Module:languages").getByCode(lang) or error("The language code \"" .. lang .. "\" is not valid.")
sc = (sc and (require("Module:scripts").getByCode(sc) or error("The script code \"" .. sc .. "\" is not valid.")) or nil)
local usex = args[compat and 1 or 2]
local translation = args[compat and 2 or 3]
local transliteration = args["tr"]
local noenum = args["noenum"]
local inline = args["inline"]
local ref = args["ref"]
local lit = args["lit"]
local qualifier = args["qualifier"]
return m_usex.format_usex(lang, sc, usex, translation, transliteration, noenum, inline, ref, quote, lit, qualifier)
end
return export