Module:Random/doc: Difference between revisions

Content deleted Content added
Date: another fix - I was obviously having a bad day when I copied these over
add limit parameter
Line 54:
== List ==
 
The <code>list</code> function outputs a list in a random order, with an optional separator.
 
&#123;{#invoke:random|list|''list item 1''|''list item 2''|''list item 3''|...|sep=''separator''|limit=''number of items to display''}}
 
'''Named parameters'''
The separator can be specified with either the {{para|sep}} or {{para|separator}} parameters.
* {{para|sep}} or {{para|separator}} - an optional separator for the list items. Some values are special; see the table below.
 
* {{para|limit}} - the maximum number of list items to display. The lowest possible is 0 and the highest possible is the length of the list.
Possible separator values:
 
{| class="wikitable"
|+ Possible separator values:
|-
! Code !! Output
Line 89 ⟶ 90:
* <code><nowiki>{{#invoke:random|list|egg|beans|sausage|bacon|spam|sep=;&amp;#32;}}</nowiki></code> &rarr; {{#invoke:random|list|egg|beans|sausage|bacon|spam|sep=;&#32;}}
* <code><nowiki>{{#invoke:random|list|egg|beans|sausage|bacon|spam|sep=foo}}</nowiki></code> &rarr; {{#invoke:random|list|egg|beans|sausage|bacon|spam|sep=foo}}
* <code><nowiki>{{#invoke:random|list|egg|beans|sausage|bacon|spam|limit=3}}</nowiki></code> &rarr; {{#invoke:random|list|egg|beans|sausage|bacon|spam|limit=3}}
 
== Text list ==
Line 94 ⟶ 96:
The <code>text_list</code> function outputs a list in a random order, text-style. In other words, it is like the <code>list</code> function, but with a different separator before the last item.
 
&#123;{#invoke:random|text_list|''list item 1''|''list item 2''|''list item 3''|...|sep=''separator''|conj=''conjunction''|limit=''number of items to display''}}
 
The separator can be specified with either the {{para|sep}} or {{para|separator}} parameters; its default value is "{{int:comma-separator}}". The conjunction can be specified with either the {{para|conj}} or {{para|conjunction}} parameters; its default value is " and ". The separator and the conjunction can be specified with the same values as the separator in the [[#List|list function]].
 
The maximum number of list items to display can be set with the {{para|limit}} parameter. The lowest possible is 0 and the highest possible is the length of the list.
 
'''Examples''' <small>({{purge|refresh|anchor=Text list}})</small>
Line 103 ⟶ 107:
* <code><nowiki>{{#invoke:random|text_list|egg|beans|sausage|bacon|spam|sep=;&amp;#32;}}</nowiki></code> &rarr; {{#invoke:random|text_list|egg|beans|sausage|bacon|spam|sep=;&#32;}}
* <code><nowiki>{{#invoke:random|text_list|egg|beans|sausage|bacon|spam|sep=;&amp;#32;|conj=&amp;#32;or&amp;#32;}}</nowiki></code> &rarr; {{#invoke:random|text_list|egg|beans|sausage|bacon|spam|sep=;&#32;|conj=&#32;or&#32;}}
* <code><nowiki>{{#invoke:random|text_list|egg|beans|sausage|bacon|spam|limit=3}}</nowiki></code> &rarr; {{#invoke:random|text_list|egg|beans|sausage|bacon|spam|limit=3}}
 
== HTML lists ==
Line 143 ⟶ 148:
; Basic usage
 
&#123;{#invoke:random|''function''|''list item 1''|''list item 2''|''list item 3''|...|limit=''number of items to display''}}
 
; All parameters
Line 162 ⟶ 167:
}}
 
The maximum number of list items to display can be set with the {{para|limit}} parameter. The lowest possible is 0 and the highest possible is the length of the list.
Please see [[Module:List]] for a full explanation of the parameters.
 
Please see [[Module:List]] for a full explanation of the other parameters.