Difference between revisions of "Template:Format item/doc"

From blackwiki
Jump to navigation Jump to search
imported>Pppery
(+ new param)
imported>Vanisaac
m (→‎See also: clean up per WP:CAT#T and WP:AWBREQ add template:Sandbox other)
 
(2 intermediate revisions by 2 users not shown)
Line 4: Line 4:
  
 
== Usage ==
 
== Usage ==
  {{((}}Format item | item = ''[[Template:Item|Item]]'' | template = ''TransformationTemplate'' | blanks = '''yes/no'''... }}
+
  {{((}}Format item | item = ''[[Template:Item|Item]]'' | template = ''TransformationTemplate'' | ... }}
<code>''TransformationTemplate''</code> is called with the parameters that the item has been created with, plus any additional parameters passed to {{tl|Format item}}. Contents of the item take precedence over the additional parameters, unless the parameter name is prepended with {{nowrap|<code>{{nodisplay|"}}important {{nodisplay|"}}</code>.}} If the parameter name collides with the parameters of {{tl|Format item}} itself, prepend it with {{nowrap|<code>{{nodisplay|"}}param {{nodisplay|"}}</code>.}} There is no need to combine {{pre-wrap|{{nowrap|<code>{{nodisplay|"}}param {{nodisplay|"}}</code>}} {{nodisplay|&nbsp;}}}}and <code>{{nodisplay|"}}important {{nodisplay|"}}</code>, though. The optional {{para|blanks}} parameter specifies what to do with items specifying nothing. If set to yes (the default), then they are treated as usual. If set to "no", then any blank parameters from items are dropped, and if no parameters remain the template returns nothing.  
+
<code>''TransformationTemplate''</code> is called with the parameters that the item has been created with, plus any additional parameters passed to {{tl|Format item}}. Contents of the item take precedence over the additional parameters, unless the parameter name is prepended with {{nowrap|<code>important </code>.}} If the parameter name collides with the parameters of {{tl|Format item}} itself, prepend it with {{nowrap|<code>param </code>.}} There is no need to combine {{pre-wrap|{{nowrap|<code>param </code>}} }}and <code>important </code>, though.
  
 
It is also possible to [[Template:Item#Format each item using a template|transform multiple items at once]], but not with this template.
 
It is also possible to [[Template:Item#Format each item using a template|transform multiple items at once]], but not with this template.
Line 40: Line 40:
 
* {{tl|Component}}
 
* {{tl|Component}}
 
* {{tl|Item}}
 
* {{tl|Item}}
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox | |
+
<includeonly>{{Sandbox other||
 
[[Category:Wikipedia formatting and function templates]]
 
[[Category:Wikipedia formatting and function templates]]
 
}}</includeonly>
 
}}</includeonly>

Latest revision as of 05:07, 25 April 2020

This template transforms a given item using a given template.

Usage

{{Format item | item = Item | template = TransformationTemplate | ... }}

TransformationTemplate is called with the parameters that the item has been created with, plus any additional parameters passed to {{Format item}}. Contents of the item take precedence over the additional parameters, unless the parameter name is prepended with important . If the parameter name collides with the parameters of {{Format item}} itself, prepend it with param . There is no need to combine Template:Pre-wrapand important , though.

It is also possible to transform multiple items at once, but not with this template.

Examples

Markup Renders as
{{Format item
| item = {{Item|name=Tom|animal=cat}}
| template = Show pet
}}

Lua error: expandTemplate: template "Show pet" does not exist.

{{Format item
| item = {{Item|name=Tom|animal=cat}}
| template = Show pet
| legs = 4
}}

Lua error: expandTemplate: template "Show pet" does not exist.

{{Format item
| item = {{Item|name=Tom|animal=cat}}
| template = Show pet
| param legs = 4
}}

Lua error: expandTemplate: template "Show pet" does not exist.

{{Format item
| item = {{Item|name=Tom|animal=cat}}
| template = Show pet
| animal = dog
}}

Lua error: expandTemplate: template "Show pet" does not exist.

{{Format item
| item = {{Item|name=Tom|animal=cat}}
| template = Show pet
| important animal = dog
}}

Lua error: expandTemplate: template "Show pet" does not exist.

See also