Template:Flagg

 

Documentation icon Template documentation[view] [edit] [history] [purge]

{{flagg}} (flag general) is a flag template with variable output format. Using Lua instead of the standard mechanism, it allows overriding the image name and link target, and works even if a country data template for an entity does not exist (without using any expensive functions).

The template is not intended to fully supersede any specific flag templates it can simulate (see below), but can be useful for formats for which no template exists, or if its additional options are needed.

Parameters

Aliases (alternatives) for each parameter or value are given in square brackets.

Format (first unnamed parameter)

The first parameter is an alphabetic code specifying the output format. The first letter concerns the image, the second the separator, and the third the country name. The parameter is fully case-insensitive.

If any position in the parameter value is missing or has a character not corresponding to an option below, the options marked as default will be used; e.g. a first parameter equal to i, i** or izz will be read as isc.

Image (first letter)

Letter Meaning Description Example
u unlinked Image is not linked (default). Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
c country Image links to country/entity page. Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
p [f] prefix/suffix Image links to country name with prefixed and/or suffixed text (default "Flag of ..."), set using |pref= and |suff= (see below). Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
i image page Image links to file description page; use this for non-public-domain images, for which attribution is required. Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
d data template Image links to the used country data template, for use in discussion/documentation. Automatically adds redirect=no if link is a redirect. Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
x X mark No image is displayed. If the second letter is anything other than x, and o is not set, an unlinked transparent image is actually used to preserve the spacing. Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.

Separator (second letter)

Letter Meaning Description Example
s span box The flag image is put in a fixed-width <span> tag, meaning the country names are aligned in vertical lists; see documentation of {{Flaglist}} (default). Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
n non-breaking space A non-breaking space (&nbsp;) is used, like in most flag templates, including {{flag}}. Note that &nbsp; does not actually prevent wrapping between image and text in all browsers; use w as described below if needed. Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
l line break A line break (<br/>) is used as separator. Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
t table cell A table cell separator (two pipes) is used. Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
x X mark No separator is used. Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.

Name (third letter)

Letter Meaning Description Example
c country The country name links to the main country/entity page (default). Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
p prefix/suffix The country name links to the country page with prefixed or suffixed text (default "Flag of ..."), set using |pref= and |suff= (see below). Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
f full prefix/suffix Same as p, except that the prefix and/or suffix is/are displayed. Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
b both country and prefix/suffix Combined country link and prefix/suffix link: country name links to country page, while prefix and/or suffix link(s) to prefixed/suffixed title. Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
u unlinked (cf. {{flagu}}) The country name is displayed as plain text, without link. Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
d data template Country name is linked to the used country data template, for use in discussion/documentation. Automatically adds redirect=no if a redirect is used. Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
x X mark No text is displayed. Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.

Some additional options can be enabled by appending the following letters to the three-letter code in any order:

Letter Description Example
a Adds the country name (the "name" parameter, or if unset the second unnamed parameter) as alt text and mouseover for the image. If |alt= is used for a custom alt/mouseover text, this does not need to be separately set. Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
e Uses the name set in the country data template (rather than the first parameter) as display name, like in {{flagcountry}} (i.e. expands abbreviated forms). Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
o Omits the image and spacing in case the image is an invisible placeholder, i.e., only include the spacing if a flag is displayed. Useful for inline/standalone usages or horizontal lists, where name alignment is not needed. Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
Compare with:
Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
r Reverses the order of the elements, putting the image to the right of the name; cf. {{flagright}}. Doesn't affect the order of letters in the format code. Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
w Avoids wrapping by adding <span class="nowrap"></span> around the output. Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.

Entity (second unnamed parameter)

The second parameter is the country or entity name. The template attempts to read the flag and link data from "Template:Country data country"; if that does not exist, the same parameter will be used as default country link and no automatic image will be displayed. The parameter also defines the default displayed country name, if the e option above is not used.

Image parameters

|variant= [third unnamed parameter]
Specifies a variant flag image, as defined and documented in each entity's data template. For example, Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found. uses the "naval" variant of Template:Country data Germany.
|image=
Custom image name, with or without the "File:" namespace prefix. Can be used if the wanted image is not available as variant for the entity (you can alternatively request it be added at the respective data template's talk page), or if no data template exists. Set to "none" ["blank", empty string] to use an unlinked transparent image (functionally identical to the x format).
|size= [|sz=]
Sets the image size; default is 23×15 pixels (larger for some entities). You can use an explicit size in pixels (e.g. 30x20px; the "px" suffix is optional) or one of the relative sizes "xs" (half the default dimensions), "s", "m", "l" and "xl" (twice the default size).
|border=
By default, the flag icon includes a border, except if it is disabled in the entity's country data template. |border= can be set to "yes" ["y", "1"] to force a border when excluded by default, or "no" ["n", "0", empty string] to prevent one.
|align= [|al=]
Set to "left" ["l"], "center" ["centre", "c", "middle", "m"] or "right" ["r"] to set the alignment of the image for the span box (s) and table cell (t) formats. For t, the default is center; for s, it is right-aligned if r is set, else left-aligned.
|width= [|w=]
Sets the width of the span box surrounding the image for the span box (s) format, in pixels, without the "px" suffix. The default is calculated by Module:Flaglist and depends on the image size.
|alt=
Sets alt text and mouseover text for the flag image, if it is for information rather than just decoration. If the wanted text is equal to the entity name, use the a option described above.
|ilink=
Overrides the link target of the image (only use if none of the image formats above allow linking to the desired page)

Text and link parameters

|name=
Changes the displayed country name. Note that with the f format, this includes the prefix and/or suffix.
|clink= [|link=]
Overwrites the link to the country article; this is also used to construct the prefix/suffix link for the f, p and b options.
|pref=, |suff=, |plink=
|pref= and |suff= set the prefix and suffix to use for the prefix/suffix links (format letters f, p and b). The default, if neither is specified, is "Flag of" as prefix (cf. {{flagof}}) and no suffix. |plink= can be used to override the combined link.
|the=
Set to "yes" ["y", "1"] to include the article "the" before the country name in the prefix/suffix links. Example: Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.. Use |pthe= if the link needs "the" but the name doesn't, and |nthe= if the name needs it but the link doesn't.
|section=
Links to a section of the linked article without displaying the section name. If both a country link and a prefix/suffix link are used, use |csection= for a section of the country article, and |psection= for a section of the prefixed/suffixed article.
|altvar= [|avar=], |age=
Enables using one of a set of standard suffixes for linking to sports teams and militaries. The altvar and suffix data is loaded from Module:Flagg/Altvar data. The possible parameter values are the base names of the corresponding specialized templates; alias values from full sports names exist (see examples below and data page). For some entities this also changes the image to a variant specific to a sport or military branch; for example, Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found. uses the IRFU flag to represent the Irish rugby union team. For youth teams in some sports (see the data page), the age limit must be additionally set using |age=.
|nalign= [|nal=]
Sets the alignment of the text in table cell format (t). The default is left; the possible values are the same as for |align=.
|text=
Overrides the entire text; only use when necessary for any nonstandard formats. Alternatively, you can set the third letter of the format parameter to x (no text) and add custom text outside the template.
|nodata=y
Overrides attempts to use the corresponding
  1. REDIRECT Template:Template link code template, which is useful when the corresponding data template doesn't exist.

Examples

Formats:

  • Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found. (default format)
  • Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found. (default format)
  • Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
  • <span style="display:inline-block;text-align:center;">{{flagg|ilf|Fiji|sz=xl}}</span>
    Flag of Fiji

Table format & alignment:

{{flagg|utu|Jamaica}} Jamaica
{{flagg|utur|Jamaica}} Jamaica
{{flagg|utu|Jamaica|al=l|nal=l}} Jamaica
{{flagg|utu|Jamaica|al=c|nal=c}} Jamaica
{{flagg|utu|Jamaica|al=r|nal=r}} Jamaica
  • Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
  • Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
  • Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
  • Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.

Standard image & name parameters:

  • Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
  • Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
  • Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
  • Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
  • Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
  • Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
  • Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
  • Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
  • Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
  • Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
  • Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
  • Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
  • Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
  • Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
  • {{flagg|isc|Myanmar|image=Flag of None.svg}} Myanmar
  • {{flagg|isc|Myanmar|image=File:Flag of None.svg}} Myanmar

Links and altvars:

  • Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
  • Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
  • Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
  • Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
  • Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
  • Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
  • Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
  • Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
  • Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
  • Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
  • Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
  • Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
  • Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
  • Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.

Non-existing data template: A data template does exist; this documentation needs updating.

  • Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
  • Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.

Comparison with other templates

These "specialized" templates predate Flagg, and while most do not have options for custom links and images, they are probably faster because they only do two transclusions without invoking Lua.

General templates

Template Corresponding {{flagg}} syntax Example
{{flag|country}} {{flagg|unc|country}} Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
{{flagbig|country}} {{flagg|ulc|country|sz=l}} Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
{{flagc|country}} {{flagg|inc|country}} Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
{{flagcountry|country}} {{flagg|unce|country}} Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
{{flagdeco|country}} {{flagg|uxx|country}} Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
{{flagicon|country}} {{flagg|cxx|country}} Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
{{flagicon image|image}} {{flagg|uxx|image=image}} Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
{{flaglink|country|suffix}} {{flagg|unp|country|suff=suffix}} Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
{{flag+link|prefix|country}} {{flagg|unp|country|pref=prefix}} (no existence check) Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
{{flaglist|country}} {{flagg|usc|country}} Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
{{flagof|country}} {{flagg|unp|country|sz=l}} Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
{{flagright|country}} {{flagg|uncr|country}} Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
{{flagu|country}} {{flagg|unu|country}} Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
{{noflag|country}} {{flagg|xnu|country}} Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
{{noflag|[[country]]}} {{flagg|xnc|country}} Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.

Sports/military templates

The football templates are used as examples here; other sports that have separate templates work correspondingly.

Template Corresponding {{flagg}} syntax Example
{{fb|country}} {{flagg|unpe|country|avar=fb}} Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
{{fb|country|align=1}} {{flagg|uspe|country|avar=fb|al=c}} Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
{{fb-big|country}} {{flagg|ulpe|country|avar=fb|sz=l}} Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
{{fb-rt|country}} {{flagg|unpre|country|avar=fb}} Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
{{fbu|age|country}} {{flagg|unpe|country|avar=fbu|age=age}} Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
{{fbw|country}} {{flagg|unpe|country|avar=fbw}} Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
{{fbwu|age|country}} {{flagg|unpe|country|avar=fbwu|age=age}} Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
{{army|country}} {{flagg|unfe|country|avar=army}} (no automatic name override) Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
{{navy|country}} {{flagg|unfe|country|avar=navy}} (no automatic name override) Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
{{air force|country}} {{flagg|unfe|country|avar=air force}} (no automatic name override) Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.
Lua error in package.lua at line 80: module 'Module:OutputBuffer' not found.

See also

  • User:SiBr4/Flagg tests — extensive tests of the template's functions, which may also serve as additional examples