Difference between revisions of "Module:Compact list/doc"

From blackwiki
Jump to navigation Jump to search
blackwiki>Hike395
(further explanation of usage)
m (3 revisions imported)
 
(One intermediate revision by one other user not shown)
Line 5: Line 5:
  
 
Typical usage in a parent template, which gathers all arguments named "foo":
 
Typical usage in a parent template, which gathers all arguments named "foo":
<p>
+
 
 
<code><nowiki>{{#invoke:Compact list|main|foo|_limit=4}}</nowiki></code>
 
<code><nowiki>{{#invoke:Compact list|main|foo|_limit=4}}</nowiki></code>
  
 
===Examples===
 
===Examples===
 
'''Note:''' these examples have the named arguments passed to the module directly. In practice, these named arguments would be passed to the template that invokes the module.
 
'''Note:''' these examples have the named arguments passed to the module directly. In practice, these named arguments would be passed to the template that invokes the module.
<p>
+
 
 
<code><nowiki>{{#invoke:Compact list|main|ook|ook=A|spud=1234}}</nowiki></code> → A
 
<code><nowiki>{{#invoke:Compact list|main|ook|ook=A|spud=1234}}</nowiki></code> → A
<p>
+
 
 
<code><nowiki>{{#invoke:Compact list|main|ook|ook1=A|ook_2=B}}</nowiki></code> → {{enum|A|B}}
 
<code><nowiki>{{#invoke:Compact list|main|ook|ook1=A|ook_2=B}}</nowiki></code> → {{enum|A|B}}
<p>
+
 
 
<code><nowiki>{{#invoke:Compact list|main|ook|ook=A|ook1=B|ook2=C|ook3=D}}</nowiki></code> → {{enum|A|B|C|D}}
 
<code><nowiki>{{#invoke:Compact list|main|ook|ook=A|ook1=B|ook2=C|ook3=D}}</nowiki></code> → {{enum|A|B|C|D}}
<p>
+
 
 
<code><nowiki>{{#invoke:Compact list|main|ook|ook1=A|ook5=B|ook20=C|ook3000=D|ook342345=E|foofoofoo=234}}</nowiki></code> → {{collapsible list|A|B|C|D|E}}
 
<code><nowiki>{{#invoke:Compact list|main|ook|ook1=A|ook5=B|ook20=C|ook3000=D|ook342345=E|foofoofoo=234}}</nowiki></code> → {{collapsible list|A|B|C|D|E}}
<p>
+
 
 
<code><nowiki>{{#invoke:Compact list|main|ook|ook1=A|ook5=B|ook20=C|ook3000=D|ook342345=E|foofoofoo=234|_limit=5}}</nowiki></code> → {{enum|A|B|C|D|E}}
 
<code><nowiki>{{#invoke:Compact list|main|ook|ook1=A|ook5=B|ook20=C|ook3000=D|ook342345=E|foofoofoo=234|_limit=5}}</nowiki></code> → {{enum|A|B|C|D|E}}
<p>
+
 
 
<code><nowiki>{{#invoke:Compact list|main|ook|ook=A|ook1=B|ook2=C|ook3=D|ook4=E|ook5=F|ook6=G}}</nowiki></code> → {{collapsible list|A|B|C|D|E|F|G}}
 
<code><nowiki>{{#invoke:Compact list|main|ook|ook=A|ook1=B|ook2=C|ook3=D|ook4=E|ook5=F|ook6=G}}</nowiki></code> → {{collapsible list|A|B|C|D|E|F|G}}

Latest revision as of 15:48, 26 September 2020

Usage

Lua code for inside of another template (e.g., an infobox). Creates a compact list out of a set of named arguments. For example, if the argument to this module is "foo", it searches for all arguments named "foo" followed by an optional underscore followed by one or more digits. It then assembles all of the named argument into a "pretty printed" list, in numerical order. If the list is short (<= 4 long), the module uses {{enum}} to print in the "A, B, C or D" format. If it is long, it will use {{collapsible list}}. The threshold can be set with |_limit=.

Typical usage in a parent template, which gathers all arguments named "foo":

{{#invoke:Compact list|main|foo|_limit=4}}

Examples

Note: these examples have the named arguments passed to the module directly. In practice, these named arguments would be passed to the template that invokes the module.

{{#invoke:Compact list|main|ook|ook=A|spud=1234}} → A

{{#invoke:Compact list|main|ook|ook1=A|ook_2=B}} → A and B

{{#invoke:Compact list|main|ook|ook=A|ook1=B|ook2=C|ook3=D}} → A, B, C and D

{{#invoke:Compact list|main|ook|ook1=A|ook5=B|ook20=C|ook3000=D|ook342345=E|foofoofoo=234}}

{{#invoke:Compact list|main|ook|ook1=A|ook5=B|ook20=C|ook3000=D|ook342345=E|foofoofoo=234|_limit=5}} → A, B, C, D and E

{{#invoke:Compact list|main|ook|ook=A|ook1=B|ook2=C|ook3=D|ook4=E|ook5=F|ook6=G}}