Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:DisplayFunctions/doc: Difference between revisions

From Sekaipedia
Content added Content deleted
(Created page with "{{documentation subpage}} {{Lua|Module:List}} This module contains several display helper functions for the Module:InfoboxBuilder. == Functions == === image === <syntaxhighlight lang="lua"> InfoboxBuilderDisplayFunctions.image(imageSize) </syntaxhighlight> Pass the desired image size as a parameter when setting it as the display function for a row. When called, this function will return a function that uses the first parameter as the filename. === link === <syn...")
 
No edit summary
(4 intermediate revisions by the same user not shown)
Line 3: Line 3:
{{Lua|Module:List}}
{{Lua|Module:List}}


This module contains several display helper functions for the [[Module:InfoboxBuilder]].
This module contains several display helper functions for the [[Module:InfoboxBuilder]] and [[Module:DatatableBuilder]]. The only dependency this module has is [[Module:List]]; this is required to use <code>list(listType)</code> and is only loaded when needed.


== Functions ==
== Functions ==
Line 9: Line 9:
=== image ===
=== image ===
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
InfoboxBuilderDisplayFunctions.image(imageSize)
DisplayFunctions.image(imageSize)
</syntaxhighlight>
</syntaxhighlight>


Line 16: Line 16:
=== link ===
=== link ===
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
DisplayFunctions.link
InfoboxBuilderDisplayFunction.link
</syntaxhighlight>
</syntaxhighlight>


Line 23: Line 23:
=== list ===
=== list ===
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
InfoboxBuilderDisplayFunctions.list(listType)
DisplayFunctions.list(listType)
</syntaxhighlight>
</syntaxhighlight>


Line 36: Line 36:


Examples of these lists can be found on [[w:Module:List#Functions|Wikipedia's documentation for Module:List]].
Examples of these lists can be found on [[w:Module:List#Functions|Wikipedia's documentation for Module:List]].

=== trueFalseOther ===
<syntaxhighlight lang="lua">
DisplayFunctions.trueFalseOther(trueVal, falseVal, otherVal)
</syntaxhighlight>

Pass the true value, false value, and value if other as parameters when setting it as the display function for a row. When called, this function will return a function that takes a boolean value and returns the corresponding true, false, or other value.


=== yesAndNo ===
=== yesAndNo ===
<syntaxhighlight lang="lua">
DisplayFunctions.yesAndNo
</syntaxhighlight>

When called, this function will display "Yes" for <code>true</code>, "No" for <code>false</code>, and <code>nil</code> for everything else. This is a special case of <code>trueFalseOther(trueVal, falseVal, otherVal)</code>.


=== checkAndX ===
=== checkAndX ===
<syntaxhighlight lang="lua">
DisplayFunctions.checkAndX
</syntaxhighlight>

When called, this function will display "✓" for <code>true</code>, "✗" for <code>false</code>, and <code>nil</code> for everything else. This is a special case of <code>trueFalseOther(trueVal, falseVal, otherVal)</code>.


=== pluralHeader ===
=== pluralHeader ===
<syntaxhighlight lang="lua">
DisplayFunctions.pluralHeader(forms)
</syntaxhighlight>

Pass in a table of grammatical forms (see [[mw:Extension:Scribunto/Lua reference manual#mw.language:convertPlural|MediaWiki's documentation]] on the correct format) as the parameter when setting it as the display function for a row. When called, this function will return a function that selects the correct plurality based on the array passed in as parameter.

=== minutesAndSeconds ===
<syntaxhighlight lang="lua">
DisplayFunctions.minutesAndSeconds
</syntaxhighlight>

When called, this function will format a number (assumed to be seconds) into the "m:ss" format.

Revision as of 02:10, 29 April 2023

This module contains several display helper functions for the Module:InfoboxBuilder and Module:DatatableBuilder. The only dependency this module has is Module:List; this is required to use list(listType) and is only loaded when needed.

Functions

image

DisplayFunctions.image(imageSize)

Pass the desired image size as a parameter when setting it as the display function for a row. When called, this function will return a function that uses the first parameter as the filename.

link

DisplayFunctions.link

When called, this function will use the first parameter as the link.

list

DisplayFunctions.list(listType)

Pass the desired type of list as a parameter when setting it as the display function for a row. When called, this function will return a function that turns an array into a list.

Valid list types are:

  • bulleted
  • unbulleted
  • horizontal
  • ordered
  • horizontal_ordered

Examples of these lists can be found on Wikipedia's documentation for Module:List.

trueFalseOther

DisplayFunctions.trueFalseOther(trueVal, falseVal, otherVal)

Pass the true value, false value, and value if other as parameters when setting it as the display function for a row. When called, this function will return a function that takes a boolean value and returns the corresponding true, false, or other value.

yesAndNo

DisplayFunctions.yesAndNo

When called, this function will display "Yes" for true, "No" for false, and nil for everything else. This is a special case of trueFalseOther(trueVal, falseVal, otherVal).

checkAndX

DisplayFunctions.checkAndX

When called, this function will display "✓" for true, "✗" for false, and nil for everything else. This is a special case of trueFalseOther(trueVal, falseVal, otherVal).

pluralHeader

DisplayFunctions.pluralHeader(forms)

Pass in a table of grammatical forms (see MediaWiki's documentation on the correct format) as the parameter when setting it as the display function for a row. When called, this function will return a function that selects the correct plurality based on the array passed in as parameter.

minutesAndSeconds

DisplayFunctions.minutesAndSeconds

When called, this function will format a number (assumed to be seconds) into the "m:ss" format.

Cookies help us deliver our services. By using our services, you agree to our use of cookies.