<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-Hans-CN">
	<id>https://wiki.statsape.com/index.php?action=history&amp;feed=atom&amp;title=%E6%A8%A1%E6%9D%BF%3AItem%2Fdoc</id>
	<title>模板:Item/doc - 版本历史</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.statsape.com/index.php?action=history&amp;feed=atom&amp;title=%E6%A8%A1%E6%9D%BF%3AItem%2Fdoc"/>
	<link rel="alternate" type="text/html" href="https://wiki.statsape.com/index.php?title=%E6%A8%A1%E6%9D%BF:Item/doc&amp;action=history"/>
	<updated>2026-11-10T16:56:50Z</updated>
	<subtitle>本wiki上该页面的版本历史</subtitle>
	<generator>MediaWiki 1.39.6</generator>
	<entry>
		<id>https://wiki.statsape.com/index.php?title=%E6%A8%A1%E6%9D%BF:Item/doc&amp;diff=4017&amp;oldid=prev</id>
		<title>Zeroclanzhang：​创建页面，内容为“{{Documentation subpage}} {{lua|Module:Item}} This template packs structured data into a compact item, which can be passed as a parameter to another template. This allows to pass multiple structured items to that template, which can iterate over the items and extract data from them.  == Usage == The structured data item contains all parameters (both numbered ones and named ones) passed to the {{tl|Item}} template. For example, &lt;code&gt;{{tlp|Item|Alice|Bob|best{{=…”</title>
		<link rel="alternate" type="text/html" href="https://wiki.statsape.com/index.php?title=%E6%A8%A1%E6%9D%BF:Item/doc&amp;diff=4017&amp;oldid=prev"/>
		<updated>2024-01-15T17:15:11Z</updated>

		<summary type="html">&lt;p&gt;创建页面，内容为“{{Documentation subpage}} {{lua|Module:Item}} This template packs structured data into a compact item, which can be passed as a parameter to another template. This allows to pass multiple structured items to that template, which can iterate over the items and extract data from them.  == Usage == The structured data item contains all parameters (both numbered ones and named ones) passed to the {{tl|Item}} template. For example, &amp;lt;code&amp;gt;{{tlp|Item|Alice|Bob|best{{=…”&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Documentation subpage}}&lt;br /&gt;
{{lua|Module:Item}}&lt;br /&gt;
This template packs structured data into a compact item, which can be passed as a parameter to another template. This allows to pass multiple structured items to that template, which can iterate over the items and extract data from them.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
The structured data item contains all parameters (both numbered ones and named ones) passed to the {{tl|Item}} template. For example, &amp;lt;code&amp;gt;{{tlp|Item|Alice|Bob|best{{=}}Eve}}&amp;lt;/code&amp;gt; creates an item with components {{code|1{{=}}Alice}}, {{code|2{{=}}Bob}}, {{code|best{{=}}Eve}}.&lt;br /&gt;
&lt;br /&gt;
Multiple items will be passed to an example recipient template {{tlu|User:Petr Matas/sandbox/Pets}} like this:&lt;br /&gt;
{{Automarkup|1=&lt;br /&gt;
{{((}}User:Petr Matas/sandbox/Pets{{!}}owner=Bob&lt;br /&gt;
{{!}} {{((}}Item{{!}}name=Tom{{!}}animal=cat{{!}}legs=4{{))}}&lt;br /&gt;
{{!}} {{((}}Item{{!}}name=Jerry{{!}}animal=mouse{{!}}legs=4{{))}}&lt;br /&gt;
{{!}} {{((}}Item{{!}}name=Tweety{{!}}animal=bird{{!}}legs=2{{))}}&lt;br /&gt;
{{))}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Constructs available to recipient templates ==&lt;br /&gt;
=== Get a component of an item ===&lt;br /&gt;
See [[Template:Component]].&lt;br /&gt;
&lt;br /&gt;
=== Format an item using a template ===&lt;br /&gt;
See [[Template:Format item]].&lt;br /&gt;
&lt;br /&gt;
=== Format each item using a template ===&lt;br /&gt;
In the recipient template, use:&lt;br /&gt;
 {{((}}#invoke:Item|each|template=&amp;#039;&amp;#039;TransformationTemplate&amp;#039;&amp;#039;|&amp;#039;&amp;#039;Separator&amp;#039;&amp;#039;|&amp;#039;&amp;#039;Prefix&amp;#039;&amp;#039;|&amp;#039;&amp;#039;Suffix&amp;#039;&amp;#039;|...}}&lt;br /&gt;
This transforms all items using a given template. &amp;lt;code&amp;gt;&amp;#039;&amp;#039;TransformationTemplate&amp;#039;&amp;#039;&amp;lt;/code&amp;gt; is called for each item with the parameters that the item has been created with, plus any additional parameters passed to {{code|#invoke}} (see {{tl|Format item}} for details). The transformed items are separated with &amp;lt;code&amp;gt;&amp;#039;&amp;#039;Separator&amp;#039;&amp;#039;&amp;lt;/code&amp;gt; and surrounded with &amp;lt;code&amp;gt;&amp;#039;&amp;#039;Prefix&amp;#039;&amp;#039;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;#039;&amp;#039;Suffix&amp;#039;&amp;#039;&amp;lt;/code&amp;gt; (whitespace is not stripped from these three optional parameters).&lt;br /&gt;
&lt;br /&gt;
The template {{tlu|User:Petr Matas/sandbox/Pets}} from the example produces the list of pets using the following code (note the use of newline as a &amp;lt;code&amp;gt;&amp;#039;&amp;#039;Separator&amp;#039;&amp;#039;&amp;lt;/code&amp;gt; and {{code|*}} as a &amp;lt;code&amp;gt;&amp;#039;&amp;#039;Prefix&amp;#039;&amp;#039;&amp;lt;/code&amp;gt; to produce list items):&lt;br /&gt;
 {{((}}#invoke:Item|each|template=[[Template:Show pet|Show pet]]|&lt;br /&gt;
 |*}}&lt;br /&gt;
&lt;br /&gt;
=== Gather given parameter from all items ===&lt;br /&gt;
In the recipient template, use &amp;lt;code&amp;gt;{{((}}#invoke:Item|gather|parameter=&amp;#039;&amp;#039;ParameterName&amp;#039;&amp;#039;|template=&amp;#039;&amp;#039;TransformationTemplate&amp;#039;&amp;#039;}}&amp;lt;/code&amp;gt; to gather the given parameter from all items. &amp;lt;code&amp;gt;&amp;#039;&amp;#039;TransformationTemplate&amp;#039;&amp;#039;&amp;lt;/code&amp;gt; will be called &amp;#039;&amp;#039;once&amp;#039;&amp;#039; and the gathered parameters (one parameter from each item) will be passed to it.&lt;br /&gt;
&lt;br /&gt;
The template {{tlu|User:Petr Matas/sandbox/Pets}} from the example produces the total number of legs using &amp;lt;code&amp;gt;{{((}}#invoke:Item|gather|parameter=legs|template=[[Template:Sum|Sum]]}}&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* {{tl|For loop}}&lt;br /&gt;
&amp;lt;includeonly&amp;gt;{{Sandbox other||&lt;br /&gt;
[[Category:Wikipedia formatting and function templates]]&lt;br /&gt;
}}&amp;lt;/includeonly&amp;gt;&lt;/div&gt;</summary>
		<author><name>Zeroclanzhang</name></author>
	</entry>
</feed>