Module:form of/functions: Difference between revisions

Created page with "--[=[ DISPLAY_HANDLERS is a list of one or more functions that provide special handling for multipart tags. Each function takes formerly a single argument (the multipart tag),..."
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
--[=[
--[=[
DISPLAY_HANDLERS is a list of one or more functions that provide special
DISPLAY_HANDLERS is a list of one or more functions that provide special handling for multipart tags. Each function
handling for multipart tags. Each function takes formerly a single argument
takes formerly a single argument (the multipart tag), now temporarily two arguments (the multipart tag and the join
(the multipart tag), now temporarily two arguments (the multipart tag and
strategy, which can be nil to use the default), and should either return the formatted display text or nil to check the
the join strategy, which can be nil to use the default), and should either
next handler. If no handlers apply, there is a default handler that appropriately formats most multipart tags.
return the formatted display text or nil to check the next handler. If no
handlers apply, there is a default handler that appropriately formats most
multipart tags.


CAT_FUNCTIONS is a map from function names to functions of a single argument,
CAT_FUNCTIONS is a map from function names to functions of a single argument, as described in [[Module:form of/cats]].
as described in [[Module:form of/cats]]. There are two types of functions:
There are two types of functions: condition handlers (which return true or false) and spec handlers (which return a
condition handlers (which return true or false) and spec handlers (which
specification, as described in [[Module:form of/cats]]). We need to put the functions here rather than in
return a specification, as described in [[Module:form of/cats]]). We need to
[[Module:form of/cats]] because that module is loaded using mw.loadData(), which can't directly handle functions.
put the functions here rather than in [[Module:form of/cats]] because that
module is loaded using mw.loadData(), which can't directly handle functions.
]=]
]=]


Line 93: Line 88:
strategy == "and" and "-]]" or "]]"
strategy == "and" and "-]]" or "]]"
if tag == "first-person" then
if tag == "first-person" then
table.insert(els, "[[Appendix:Glossary#first person|first" .. suffix)
table.insert(els, "[[wikt:Appendix:Glossary#first person|first" .. suffix)
elseif tag == "second-person" then
elseif tag == "second-person" then
table.insert(els, "[[Appendix:Glossary#second person|second" .. suffix)
table.insert(els, "[[wikt:Appendix:Glossary#second person|second" .. suffix)
elseif tag == "third-person" then
elseif tag == "third-person" then
table.insert(els, "[[Appendix:Glossary#third person|third" .. suffix)
table.insert(els, "[[wikt:Appendix:Glossary#third person|third" .. suffix)
else
else
return nil
return nil
Line 107: Line 102:


return export
return export
-- For Vim, so we get 4-space tabs
-- vim: set ts=4 sw=4 noet: