ମଡ୍ୟୁଲ:Separated entries
Appearance
![]() | This module issubject to page protection.It is ahighly visible modulein use by a very large number of pages, or issubstitutedvery frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it isprotectedfrom editing. |
![]() | This Lua module is used on୧୧,୫୦,୦୦୦+ pages, or roughly 1424% of all pages. To avoid major disruption and server load, any changes should be tested in the module's/sandboxor/testcasessubpages, or in your ownmodule sandbox.The tested changes can be added to this page in a single edit. Consider discussing changes on thetalk pagebefore implementing them. |
Usage[ସମ୍ପାଦନା]
Module:Separated entriesserves as a template front-end tomw.text.listToText
.It takesany numberof positional parameters andpieces them togetherwith|separator=
.|conjunction=
can be optionally defined if a different separator is desired between the last and second last items. Leading and trailing whitespace is stripped; if the|separator=
should contain spaces, use the HTML escape code 
.Separated entries does not raise any errors by design.
{{#invoke:Separated entries|main|separator=...}}
-- This module takes positional parameters as input and concatenates them with
-- an optional separator. The final separator (the "conjunction" ) can be
-- specified independently, enabling natural-language lists like
-- "foo, bar, baz and qux". The starting parameter can also be specified.
localcompressSparseArray=require('Module:TableTools').compressSparseArray
localp={}
functionp._main(args)
localseparator=args.separator
-- Decode (convert to Unicode) HTML escape sequences, such as " " for space.
andmw.text.decode(args.separator)or''
localconjunction=args.conjunctionandmw.text.decode(args.conjunction)orseparator
-- Discard values before the starting parameter.
localstart=tonumber(args.start)
ifstartthen
fori=1,start-1doargs[i]=nilend
end
-- Discard named parameters.
localvalues=compressSparseArray(args)
returnmw.text.listToText(values,separator,conjunction)
end
localfunctionmakeInvokeFunction(separator,conjunction,first)
returnfunction(frame)
localargs=require('Module:Arguments').getArgs(frame)
args.separator=separatororargs.separator
args.conjunction=conjunctionorargs.conjunction
args.first=firstorargs.first
returnp._main(args)
end
end
p.main=makeInvokeFunction()
p.br=makeInvokeFunction('<br />')
p.comma=makeInvokeFunction(mw.message.new('comma-separator'):plain())
returnp