(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. It can also be used in conjunction with Module:Flag to reduce post-expand include size of pages with lots of templates.   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.  First letter: Image  Letter  Meaning  Description  Example u  unlinked  Image is not linked (default).   c  country  Image links to country/entity page.   p [f]  prefix/suffix  Image links to country name with prefixed and/or suffixed text (default "Flag of ..."), set using  and  (see below).   i  image page  Image links to file description page; use this for non-public-domain images, for which attribution is required.   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.   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.    Second letter: Separator  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  (default).  n  non-breaking space  A non-breaking space (&nbsp;) is used, like in most flag templates, including . Note that &nbsp; does not actually prevent wrapping between image and text in all browsers; use w as described below if needed.  l  line break  A line break (<br/>) is used as separator.  t  table cell  A table cell separator (two pipes) is used.   x  X mark  No separator is used.   Third letter: Name  Letter  Meaning  Description  Example c  country  The country name links to the main country/entity page (default).   p  prefix/suffix  The country name links to the country page with prefixed or suffixed text (default "Flag of ..."), set using  and  (see below).   f  full prefix/suffix  Same as p, except that the prefix and/or suffix is/are displayed.   l  link target  Same as p, except that the target of the link is displayed.   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.   u  unlinked (cf. )  The country name is displayed as plain text, without link.   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.   a  abbreviation  Country name is not linked, but the name of the main country/entity page is presented as mouseover text if it is different.   x  X mark  No text is displayed.   *  Add *  Similar to "p", except that an asterisk (*) is added to the text of the link if it goes to a more specific article.   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  is used for a custom alt/mouseover text, this does not need to be separately set.   b  Blanks the text portion if a flag is not found.  Compare with: e  Uses the name set in the country data template (rather than the first parameter) as display name, like in  (i.e. expands abbreviated forms).   f  If the prefixed/suffixed article name doesn't exist, fallback to linking to the non-prefixed/suffixed page. This may be expensive, and the number of time it can be used on single page is limited.  Compare with: i  Uses the IOC country codes table from Module:Country alias/data to resolve the country data from the entity parameter.  Compare with: l  Adds the link name (as defined by the "image" parameter) as alt text and mouseover for the image. If  is used for a custom alt/mouseover text, this does not need to be separately set.  Compare with: 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.  Compare with: p  Wraps the text in Parentheses.   r  Reverses the order of the elements, putting the image to the right of the name; cf. . Doesn't affect the order of letters in the format code.   w  Avoids wrapping by adding  around the output.   t  Aligns to the left in a table.     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  option above is not used.   Image parameters   [third unnamed parameter] Specifies a variant flag image, as defined and documented in each entity's data template. For example,  uses the "naval" variant of Template:Country data Germany.  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  format).  [] 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).  By default, the flag icon includes a border, except if it is disabled in the entity's country data template.  can be set to "yes" ["y", "1"] to force a border when excluded by default, or "no" ["n", "0", empty string] to prevent one.  [] Set to "left" ["l"], "center" ["centre", "c", "middle", "m"] or "right" ["r"] to set the alignment of the image for the span box () and table cell () formats. For , the default is center; for , it is right-aligned if  is set, else left-aligned.  [] Sets the width of the span box surrounding the image for the span box () format, in pixels, without the "px" suffix. The default is calculated by Module:Flaglist and depends on the image size.  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  option described above.  Overrides the link target of the image (only use if none of the image formats above allow linking to the desired page).  Displays a red link to the missing country data template instead of a placeholder image. If set to notext, no text will be displayed alongside the red link. Defaults to "yes" (no red link displayed).  Adds the page to category name if the image if the country data is missing.   Text and link parameters   Changes the displayed country name. Note that with the  format, this includes the prefix and/or suffix.  [] Overwrites the link to the country article; this is also used to construct the prefix/suffix link for the ,  and  options. , ,   and  set the prefix and suffix to use for the prefix/suffix links (format letters ,  and ). The default, if neither is specified, is "Flag of" as prefix (cf. ) and no suffix.  can be used to override the combined link.  Set to "yes" ["y", "1"] to include the article "the" before the country name in the prefix/suffix links. Example: . Use  if the link needs "the" but the name doesn't, and  if the name needs it but the link doesn't.  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  for a section of the country article, and  for a section of the prefixed/suffixed article.  [],  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,  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 .  [] Sets the alignment of the text in table cell format (). The default is left; the possible values are the same as for .  Adds a text-only prefix that is not included in the link. This text is not affected by any option other than  for blanking text if no flag found. It will be separated from the link text by &nb‍sp; unless the  or  separator options are specified (in which case it will use nothing or a line break, respectively).  Overrides the entire text; only use when necessary for any nonstandard formats. Alternatively, you can set the third letter of the format parameter to  (no text) and add custom text outside the template.  Overrides attempts to use the corresponding  template, which is useful when the corresponding data template doesn't exist. , , ,   If the f extra is specified, and the prefix/suffixed article name being linked to doesn't exist, then use these parameters as an alternate prefix/suffix, and check if it exists as well. (If it still doesn't exist, then fall back to the non-prefixed/suffixed page as normal). This may be expensive, and the number of time it can be used on single page is limited.   Examples  Formats:  (default format)  (default format)  <span style="display:inline-block;text-align:center;">flagg|ilf|Fiji|sz=xl</span> →   Table format & alignment:                  Standard image & name parameters:  flagg|isc|Myanmar|image=Flag of None.svg →  flagg|isc|Myanmar|image=File:Flag of None.svg →   Links and altvars:  Non-existing data template:    Adding links to specialized country, state, etc. articles. With asterisk  See also: Help:Table#Adding links to specialized country, state, etc. articles. With asterisk.  Section below copied from there. Please update here as changes are made there.  For example: List of U.S. states and territories by incarceration and correctional supervision rate List of countries by incarceration rate  Once you have a table with , and/or other flag template such as , it is easy to convert the links to specialized links. So instead of Oklahoma you would have Incarceration in Oklahoma, or if that article does not exist, then Crime in Oklahoma.   This works with full country or US state names. Also with abbreviated (3-letter) country names, and abbreviated (2-letter) US state names.   Use a global find-and-replace as previously described, but without regular expressions. Replace:  {{flag| or {{flaglist|  with  {{flagg|us*eft|pref=Incarceration in|pref2=Crime in|  The bar after flag or flaglist is necessary to avoid problems in case you have to replace 2 flag templates.   The  template looks for the articles. If it finds one of the two choices it adds the link and an asterisk after the location name. If it does not find either article, it just adds the standard link.  Substitute your preferred topics in the pref= and pref2= spots.  {{flagg|us*eft| usually left aligns the text of that column (due to the "t" at the end of the code). For some unknown reason that is not always true. In that case each cell in that column will need style=text-align:left in it. Or use the whole column code described here: #Column alignment and here: . See example table.   Washington, D.C. - Have to force the full name to be shown:  {{flagg|us*eft|pref=Crime in|Washington, D.C.|name=Washington, D.C.}}  This particular use of  parameters is expensive and can only be used on a few hundred links per article. Every time the article is saved it occurs, even for null edits. So only one big country table per article. Other country tables in the same article should use standard links.  In List of countries by incarceration rate the  template creates a link to Incarceration in United States. That link is a redirect to Incarceration in the United States. Add "the" as necessary to create redirect pages. Admins will delete redirects that are not linked from within Wikipedia. So if you need to create redirects be sure to use them right away in an article table. Or keep them in a sandbox that the admins can see until you use them in an article table. See examples. See list.   removes the names of the countries behind territories, subnational areas, etc.. This makes for more compact tables. Other flag templates (such as ) do not do that. But that template can not create specialized country links.  See Global Search at Toolforge. Search for  "{{flagg|us*eft" - in quotes. To get transclusion count and list of articles.  The  template does not work if colspan is used before the country/state name.  works. See: Template talk:Flagg#Does not work with colspan. See section farther down for  info: #Without asterisks. Only one preference.   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  TemplateCorresponding  syntaxExample (no existence check) (expensive)   Sports/military templates  The football templates are used as examples here; other sports that have separate templates work correspondingly. TemplateCorresponding  syntaxExample   See also  Module:Flag — a lua wrapper for Module:Flagg designed to easily replace some common flag templates User:SiBr4/Flagg tests — extensive tests of the template's functions, which may also serve as additional examples