Module:Road data/strings/doc
![]() | This is a documentation subpage for Module:Road data/strings. It may contain usage information, categories and other content that is not part of the original module page. |
This module is used to store type data for use with several road templates, including {{jct}} and {{routelist row}}. Background information and a summary of the syntax are listed below.
Syntax
Hierarchy and fields
At its most basic level, this module is a nested table of strings. At the top is the root table, usually the abbreviation of a country, state, or province. This table stores the type data for a particular place, which is named in the comment in the first line, and is returned at the end of the module. The table is composed of further tables, one per type. The basic syntax for a type table is:
place.type = {shield = "",
link = "",
abbr = ""}
The three main fields in a type table are shield
, link
, and abbr
. Generally, shield
determines the shield that is displayed, if any; link
specifies the target of the link generated by a including module, if any; and abbr
determines the displayed abbreviation. Currently, these are the three types used by all countries. By convention, they are always specified, using an empty string if there is no value.
Two additional fields are used in the United States. banner
stores the name of the banner file, while width
stores a code representing the width of the shield. Unlike the three main fields, these are generally omitted entirely when unused.
Once a type is defined, it can be referred to later in the code. A common idiom used for bannered types is defining the shield to be the shield field of the base type (from Module:Road data/strings/USA/MO):
MO.US = {shield = "US %route%.svg",
link = "U.S. Route %route% in Missouri",
abbr = "US %route%",
width = "expand"}
MO["US-Alt"] = {shield = MO.US.shield,
link = "U.S. Route %route% Alternate ([dab||%dab%, |]Missouri)",
abbr = "US %route% Alt.",
banner = "Alternate plate.svg",
width = "expand"}
Another common idiom is defining a type alias by setting an entry in the root table equal to a previously defined type (from Module:Road data/strings/HKG):
HKG.Route = {shield = "HK Route%route%.svg",
link = "Route %route% (Hong Kong)",
abbr = "Route %route%"}
HKG.route = HKG.Route