မေႃႇၵျူး:CountryData/doc
This is the documentation page for မေႃႇၵျူး:CountryData
This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing. |
Lua module ဢၼ်ၼႆႉ လႆႈၸႂ်ႉဝႆႉ တီႈၼႃႈလိၵ်ႈ many ၼႃႈလိၵ်ႈ လႄႈ လွင်ႈလႅၵ်ႈလၢႆႈၸိူဝ်းၼႆႉ တေႁႂ်ႈၽၢင်ႉမႅၼ်ႈၺႃး ၵႂၢင်ႈၵႂၢင်ႈၶႂၢင်ၶႂၢင်။ ၸၢမ်းတူၺ်း လွင်ႈလႅၵ်ႈလၢႆႈ တီႈၼႂ်း မေႃႇၵျူး's /sandbox ဢမ်ႇၼၼ် ၼႃႈလိၵ်ႈၽႄ /testcases . ဝူၼ်ႉသွၼ်ႇ ဢုပ်ႇဢူဝ်း လွင်ႈလႅၵ်ႈလၢႆႈ တီႈၼႂ်း ၼႃႈလိၵ်ႈ တႃႇဢုပ်ႇ ၽွင်းမိူဝ်ႈပႆႇ ၵေႃႇသၢင်ႈၶဝ်ၼၼ်ႉ။
ႁူဝ်ၼပ်ႉ လွင်ႈၶဝ်ႈပႃးၼႆႉ မၼ်းႁဵတ်းဢၢပ်ႉတဵတ်ႉဝႆႉႁင်းမၼ်း (တူၺ်းတီႈ ၽိုၼ်လိၵ်ႈ)။ |
This module has three functions to extract data from country data templates (which are used for most flag templates).
gettable
[မႄးထတ်းငဝ်ႈငႃႇ]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 require('Module:CountryData').gettable(parameters)
.
The first parameter is the frame
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 |age=
or |mw=
, which are used in the values of some sports alias parameters. E.g.,
local data = require('Module:CountryData').gettable(frame,"France",{age="20",mw="men's"})
The function returns an empty table if a data template does not exist or does not conform to the standard structure.
getalias
[မႄးထတ်းငဝ်ႈငႃႇ]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, {{#invoke:CountryData|getalias|France|flag alias}}
→ Flag of France.svg. The other parameters are |variant=
to return a variant parameter value, with fallback to the main field value if the variant does not exist, and |def=
for the fallback output if the wanted data template or field does not exist, the default for which is a literal "nil".
Note: This is likely not quicker than wikicode-only alternatives such as {{getalias}} and {{getalias2}}, 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 "nil" (or the value of |def=
) rather than a redlink to the data template. See a comparison of the four at User:SiBr4/Flagg tests#Lua-based getalias.
gettemplate
[မႄးထတ်းငဝ်ႈငႃႇ]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:
{{#tag:pre|{{Country data France}}}} {{#tag:pre|{{#invoke:CountryData|gettemplate|France}}}}
gives
{{ {{{1}}} | alias = မိူင်းၾရၢင်ႇသဵတ်ႈ | shortname alias = ၾရၢင်ႇသဵတ်ႈ | flag alias = Flag of France.svg | flag alias-1790 = Flag of France (1790-1794).svg | flag alias-1814 = Flag of France (1814–1830).svg | flag alias-naval = Civil and Naval Ensign of France.svg | flag alias-naval-1790 = Flag of French-Navy-Revolution.svg | link alias-naval = French Navy | size = | name = | altlink = | variant = }}
{{ {{{1}}} | flag alias-naval = Civil and Naval Ensign of France.svg | flag alias-naval-1790 = Flag of French-Navy-Revolution.svg | flag alias-1790 = Flag of France (1790-1794).svg | shortname alias = ၾရၢင်ႇသဵတ်ႈ | flag alias = Flag of France.svg | altlink = | name = | variant = | flag alias-1814 = Flag of France (1814–1830).svg | link alias-naval = French Navy | alias = မိူင်းၾရၢင်ႇသဵတ်ႈ | size = }}
Note that, like with all Lua tables, the order of entries is not preserved, so the parameters are mixed up.