Module:Icon/doc
More actions
This is the documentation page for Module:Icon
Renders an icon as wikitext, with optional trailing text and an optional link on that text. It is the rendering core of the icon system: Template:Icon invokes it directly with a filename, and dataset wrapper templates such as Template:Ammo and Template:Currency invoke it with a dataset name and key.
The module exposes a single public entry point: Icon.main, the {{#invoke:}} entry point used by all templates. It accepts either a direct icon filename or a dataset name and key. When a filename is supplied, the module looks it up in Module:Icon/index to resolve CSS classes; when a dataset name and key are supplied, it resolves the entry directly from the named dataset. It produces a TemplateStyles tag followed by the icon image, and a styled label span containing the text when text is supplied.
Editors placing an icon on a page should use Template:Icon rather than invoking this module directly.
Arguments
The module accepts two mutually exclusive input paths.
Direct path, used by Template:Icon:
icon(required): file name of the icon.
Dataset path, used by wrapper templates:
dataset(required): name of the dataset atModule:Icon/data/<dataset>.key(required): lookup key within the dataset; lowercased before matching.
The following optional arguments apply to both paths:
text(optional): label rendered after the icon.link(optional): link target for the label. Treated as an internal page name unless it begins with a URL scheme or//, in which case it is rendered as an external link.size(optional): pixel size of the icon image; defaults to 22.
Errors
Raises an error when no icon can be determined, when dataset or key is supplied without the other, when the named dataset does not exist, or when the supplied key is not found in the dataset. All errors are caught by main, rendered as an inline <span class="error">, and tracked via Category:Pages with icon errors.
See also
- Module:Icon/data: dataset documentation for the icon system.
- Module:Icon/index: maps icon filenames to dataset locations.
- Template:Icon/styles.css: the stylesheet loaded by this module.