Jump to content
 







Main menu
   


Navigation  



Main page
Contents
Current events
Random article
About Wikipedia
Contact us
Donate
 




Contribute  



Help
Learn to edit
Community portal
Recent changes
Upload file
 








Search  



























Create account

Log in
 









Create account
 Log in
 




Pages for logged out editors learn more  



Contributions
Talk
 



















Contents

   



(Top)
 


1 Usage  





2 See also  














Module:Separated entries






Afrikaans
Алтай тил
Anarâškielâ
Аԥсшәа
العربية
Արեւմտահայերէն
Avañe'
Azərbaycanca
تۆرکجه
Basa Bali

 / Bân-lâm-gú
Башҡортса
Беларуская
Беларуская (тарашкевіца)

Bikol Central
Български

Bosanski
Буряад
Català
Чӑвашла
Chamoru
ChiShona
Corsu
Cymraeg
Dansk
الدارجة
Deutsch

Eesti
Ελληνικά
Эрзянь
Español
Euskara
فارسی
Føroyskt
Français
Furlan
Gaeilge
Galego
ГӀалгӀай

گیلکی

  / Gõychi Konknni
/Hak-kâ-ngî
Хальмг

Hausa
Hawaiʻi
Հայերեն
ि
Hrvatski
Bahasa Hulontalo
Ilokano
Bahasa Indonesia
Interlingua
Ирон
Íslenska
Italiano
עברית
Jawa


Қазақша
Ikinyarwanda
Ikirundi
Kurdî
Ladin
Latviešu
Lëtzebuergesch
Lietuvių
Luganda
ि
Македонски

Malti
Māori


مصرى

Bahasa Melayu
Mfantse
Minangkabau
 / Mìng-dĕ̤ng-nḡ
Мокшень

Na Vosa Vakaviti
Nederlands


Нохчийн
Norfuk / Pitkern
Norsk bokmål
Occitan
ି
Oʻzbekcha / ўзбекча

Pangcah


Polski
Português
Qaraqalpaqsha
Română
Русский
Sakizaya

Scots
Setswana
Shqip

Simple English
سنڌي
Slovenščina
کوردی
Српски / srpski
Srpskohrvatski / српскохрватски
Sunda
Suomi
Svenska
Tagalog
ி
Taqbaylit
Tarandíne
Татарча / tatarça
 
Tayal

Тоҷикӣ
Türkçe
Удмурт
Українська
اردو
Vèneto
Tiếng Vit
Volapük

Winaray



Ghanaian Pidgin
 

Edit links
 









Module
Talk
 

















Read
View source
View history
 








Tools
   


Actions  



Read
View source
View history
 




General  



What links here
Related changes
Upload file
Special pages
Permanent link
Page information
Get shortened URL
Download QR code
Wikidata item
 




Print/export  



Download as PDF
Printable version
 




In other projects  



Wikimedia Commons
MediaWiki
Meta-Wiki
Wikimedia Outreach
Wikispecies
Wikidata
Wikiversity
 

















Permanently protected module

From Wikipedia, the free encyclopedia
 


Usage

Module:Separated entries serves as a template front-end to mw.text.listToText. It takes any number of positional parameters and pieces them together with |separator=. |conjunction= can be optionally defined if a different separator is desired between the last and second last items. The starting positional parameter can be specified using |start=. Leading and trailing whitespace is stripped. To add deliberate leading and trailing whitespace, use the HTML entity   for a space and 
 for a "newline". Separated entries does not raise any errors by design.

{{#invoke:separated entries|main|separator=...}}

For more complex cases – such as selecting the parameters to list, or preprocessing them, or omitting the last parameters – {{#invoke:params|list_values}} is available. The following two examples with “ + ” as delimiter and “ ... ” as conjunction produce a similar result:

  1. {{#invoke:separated entries|main|separator= + |conjunction= ... }}
  2. {{#invoke:params|sequential|squeezing|trimming_values|setting|i/l| + | ... |list_values}}

See also

-- 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.

local compressSparseArray = require('Module:TableTools').compressSparseArray
local p = {}

function p._main(args)
 local separator = args.separator
  -- Decode (convert to Unicode) HTML escape sequences, such as " " for space.
  and mw.text.decode(args.separator) or ''
 local conjunction = args.conjunction and mw.text.decode(args.conjunction) or separator
 -- Discard values before the starting parameter.
 local start = tonumber(args.start)
 if start then
  for i = 1, start - 1 do args[i] = nil end
 end
 -- Discard named parameters.
 local values = compressSparseArray(args)
 return mw.text.listToText(values, separator, conjunction)
end

local function makeInvokeFunction(separator, conjunction, first)
 return function (frame)
  local args = require('Module:Arguments').getArgs(frame)
  args.separator = separator or args.separator
  args.conjunction = conjunction or args.conjunction
  args.first = first or args.first
  return p._main(args)
 end
end

p.main = makeInvokeFunction()
p.br = makeInvokeFunction('<br />')
p.comma = makeInvokeFunction(mw.message.new('comma-separator'):plain())

return p

Retrieved from "https://en.wikipedia.org/w/index.php?title=Module:Separated_entries&oldid=874210307"

Categories: 
Modules subject to page protection
Wikipedia metatemplates
Hidden category: 
Wikipedia fully protected modules
 



This page was last edited on 17 December 2018, at 20:54 (UTC).

Text is available under the Creative Commons Attribution-ShareAlike License 4.0; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.



Privacy policy

About Wikipedia

Disclaimers

Contact Wikipedia

Code of Conduct

Developers

Statistics

Cookie statement

Mobile view



Wikimedia Foundation
Powered by MediaWiki