<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://mywikibiz.com/index.php?action=history&amp;feed=atom&amp;title=Module%3ACountryData%2Fdoc</id>
	<title>Module:CountryData/doc - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://mywikibiz.com/index.php?action=history&amp;feed=atom&amp;title=Module%3ACountryData%2Fdoc"/>
	<link rel="alternate" type="text/html" href="https://mywikibiz.com/index.php?title=Module:CountryData/doc&amp;action=history"/>
	<updated>2026-06-13T23:11:44Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.3</generator>
	<entry>
		<id>https://mywikibiz.com/index.php?title=Module:CountryData/doc&amp;diff=471414&amp;oldid=prev</id>
		<title>Zoran: Pywikibot 6.4.0</title>
		<link rel="alternate" type="text/html" href="https://mywikibiz.com/index.php?title=Module:CountryData/doc&amp;diff=471414&amp;oldid=prev"/>
		<updated>2021-07-15T21:13:06Z</updated>

		<summary type="html">&lt;p&gt;Pywikibot 6.4.0&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Module rating|protected}}&lt;br /&gt;
This module has three functions to extract data from [[:Category:Country data templates|country data templates]] (which are used for most [[WP:WPFT|flag templates]]).&lt;br /&gt;
&lt;br /&gt;
=== gettable ===&lt;br /&gt;
Extracts all parameters from a data template and returns them as a Lua table. This function is only usable from other Lua modules; invoke it using &amp;lt;code&amp;gt;require('Module:CountryData').gettable(''parameters'')&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The first parameter is the &amp;lt;code&amp;gt;frame&amp;lt;/code&amp;gt; of the invoking module; the second is the country or other entity to get the data of. The optional third parameter is a table of parameters to pass into the data template; this may, for example, include {{para|age}} or {{para|mw}}, which are used in the values of some sports alias parameters. E.g.,&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Lua&amp;quot;&amp;gt;local data = require('Module:CountryData').gettable(frame,&amp;quot;France&amp;quot;,{age=&amp;quot;20&amp;quot;,mw=&amp;quot;men's&amp;quot;})&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The function returns an empty table if a data template does not exist or does not conform to the [[WP:WPFT#Basic country data template structure|standard structure]].&lt;br /&gt;
&lt;br /&gt;
=== getalias ===&lt;br /&gt;
If used from wikicode, this function returns the value of a single field in a data template. The first parameter is the country or other entity whose data to return; the second is the name of the field. For example, &amp;lt;code&amp;gt;{{((}}#invoke:CountryData|getalias|France|flag alias{{))}}&amp;lt;/code&amp;gt; &amp;amp;rarr; {{#invoke:CountryData|getalias|France|flag alias}}. The other parameters are {{para|variant}} to return a variant parameter value, with fallback to the main field value if the variant does not exist, and {{para|def}} for the fallback output if the wanted data template or field does not exist, the default for which is a literal &amp;quot;nil&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Note: This is likely not quicker than wikicode-only alternatives such as {{tl|getalias}}, {{tl|getalias2}} and {{tl|pst name}}, because it transcludes the data template from Lua and converts it to a Lua table using the above function, picks the wanted parameter name, and returns it to wikicode, whereas other templates perform two simple non-Lua transclusions to get, in most cases, the same result. The Lua version does have the advantage that using it with a non-existing country data template returns &amp;quot;nil&amp;quot; (or the value of {{para|def}}) rather than a redlink to the data template. See a comparison of the four at [[User:SiBr4/Flagg tests#Lua-based getalias|User:SiBr&amp;lt;sub&amp;gt;4&amp;lt;/sub&amp;gt;/Flagg tests#Lua-based getalias]].&lt;br /&gt;
&lt;br /&gt;
=== gettemplate ===&lt;br /&gt;
This function concatenates the fields of a data template into a string similar to what you get when transcluding it directly. It can be compared with a direct transclusion to test if a template is being converted to Lua correctly:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{{#tag:pre|{{Country data France}}}}&lt;br /&gt;
{{#tag:pre|{{#invoke:CountryData|gettemplate|France}}}}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
gives&lt;br /&gt;
{{#tag:pre|{{Country data France}}}}&lt;br /&gt;
{{#tag:pre|{{#invoke:CountryData|gettemplate|France}}}}&lt;br /&gt;
&lt;br /&gt;
Note that, like with all Lua tables, the order of entries is not preserved, so the parameters are mixed up.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;includeonly&amp;gt;{{Sandbox other | |&lt;br /&gt;
[[Category:Flag template system]]&lt;br /&gt;
}}&amp;lt;/includeonly&amp;gt;&lt;/div&gt;</summary>
		<author><name>Zoran</name></author>
	</entry>
</feed>