Template:Sprintf/doc

This is the current revision of this page, as edited by Alex (talk | contribs) at 00:47, 17 October 2024 (Created page with "{{Documentation}} {{invokes|sprintf}} Provides access to the lua [https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#string.format string.format] function. ==Usage== <pre>{{Sprintf|format string|param1|param2|...|paramN}}</pre> The format string is specified according to [https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#string.format string.format], which uses [http://www.cplusplus.com/reference/cstdio/printf/ printf formatti..."). The present address (URL) is a permanent link to this version.

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
This is a documentation subpage for Template:Sprintf.
It contains usage information, categories, and other content that is not part of the original template page.
Template:Sprintf invokes function main in Module:Sprintf using Lua.
Template:Sprintf invokes Module:sprintf using Lua.

Provides access to the lua string.format function.

Usage

{{Sprintf|format string|param1|param2|...|paramN}}

The format string is specified according to string.format, which uses printf formatting with a few exceptions. See documentation for full details. The paramters should be provided as required by the format string.

Examples

* Two strings: {{Sprintf|%s - %s|abyssal|whip}}
* Floating point formatting: {{Sprintf|%3.2f|12345.678901}}
* Hexadecimal conversion: {{Sprintf|%x|100}}
  • Two strings: abyssal - whip
  • Floating point formatting: 12345.68
  • Hexadecimal conversion: 64

Template data

Show/hide template's data

The following information is used by extensions and applications, such as VisualEditor, to help users implement this template onto pages. Please ensure that it is up-to-date.


Provides access to the lua string formatting function.

Template parameters

This template prefers inline formatting of parameters.

ParameterDescriptionTypeStatus
Format string1

no description

Unknownrequired
Parameter 12

Param to be inserted in the first replacement position.

Stringrequired
Parameter 23

Second parameter (repeat for as many as are specified by the format string)

Unknownoptional