Template:Sprintfexpr

This is the current revision of this page, as edited by Alex (talk | contribs) at 00:47, 17 October 2024 (Created page with "<includeonly>{{#invoke:sprintf|expr}}</includeonly><noinclude>{{/doc}}</noinclude>"). The present address (URL) is a permanent link to this version.

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Template documentation
This documentation is transcluded from Template:Sprintfexpr/doc. [edit] [history] [purge]
Template:Sprintfexpr invokes function expr in Module:Sprintf using Lua.
Template:Sprintfexpr invokes Module:sprintf using Lua.

A subtemplate of Template:Sprintf, that only takes one argument and automatically uses #expr on it.

Provides access to the lua string.format function.

Usage

{{Sprintfexpr|format string|param}}

The format string is specified according to string.format, which uses printf formatting with a few exceptions. See documentation for full details. Only one parameter is added, so your format string should only include one replacement string

Examples

* One decimal place: {{Sprintfexpr|%.1f|1.2*5.6*82.23654}}
* One decimal place (when an int): {{Sprintfexpr|%.1f|5*5}}
* Padding left as int: {{Sprintfexpr|%05d|2*2}}
  • One decimal place: 552.6
  • One decimal place (when an int): 25.0
  • Padding left as int: 00004

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[Edit template data]

This template prefers inline formatting of parameters.

ParameterDescriptionTypeStatus
Format string1

no description

Unknownrequired
Parameter2

Param to be inserted in the replacement position. Automatically #expr'd

Stringrequired