Template:Routemap/doc

This Lua-based template replaces the older parser-function-based BS-map (and deprecated Railway line header, BS-header and BS-table) templates for Route diagram templates because diagrams created by &#123;&#123;Routemap}} load faster.

Usage


Markup for map parameter
The markup for composing the diagram in the map parameter is different to the BSrow-based templates. The major differences are the separators in each row. Subtemplates are not necessary, since a new row in the table is simply created by a carriage return (newline).

Basic

 * Icons are separated by the backslash.
 * Each group of icons is centered in its row. The nameless icon (at the start of row 5 in the diagram) can be used as a spacer.
 * The ID of each icon can be seen in its tooltip. Move your cursor over the icons to see them.

Sidebar text
or


 * The third and fourth pairs of tildes can be omitted if there is no content following either of them.
 * After the last icon ID, if there is only one set of "tilde-tilde" (
 * style="vertical-align:top;"|
 * }

The asterisk indicating a text cell can be preceded by one of the BSicons' width prefixes. (Normal BSicons are square.)

Icon overlay, icon link, background color and colspan

 * Overlay separator "exclamation mark-tilde" must follow the icon ID which is to be overlaid.
 * Overlay is practically unlimited, but legibility should be taken into account.
 * The width of the underlying icon determines the width of the combination, even if less than the overlay. The icons are aligned with their left edges together, so that they will not be centered on each other if they differ in width. If the overlay extends past the underlying icon, it will overlay the following icon (but not the following icon's overlay).
 * When using icon overlay and icon link for the same icon cell, the icon link separator must follow the last (top) overlaying icon ID.
 * The background color parameter requires 5 sets of preceding text separators to be recognizable even if there is no text on that row whatsoever.

Rows
Aside from, there are several other parameters, separated by commas , which can be used to customize the display of a row. Only  can be used to change the display of icons; all others only affect text cells.

Individual cells/icons

 * Parameters for a single icon or text cell (e.g.,  ) are preceded by two underscores.
 * Parameters for the contents of a table cell (a stack of overlaid objects, or a single icon or text box with no overlays) are preceded by an exclamation mark and an underscore . This must follow the link (if any).
 * For the last overlaid item in a stack, the individual item parameters (if any) must precede the stack parameters.
 * Most of the parameters are the same as those for rows, but there are a few additional ones. Additionally, the values for,   and   will override the row parameter values.

Collapsible

 * Adjust text-width (or tw) parameter until there is no break.
 * Unit is "px" by default, but other units such as "em" are acceptable.
 * Check the map in different browser and in mobile view, and increase text-width if it breaks.
 * The icon number of the first row of collapsible section must be equal to or greater than the icon number of the widest non-collapsible row.
 * As in example 3.2, use half-width empty icon as filler when you are mixing both odd and even rows in the same map.
 * Changing "collapsed" to "nil" will change the default state of the collapible section to uncollapsed.

Collapsible replacement

 * Both replacement and replaced rows must be as wide as the widest non-collapsible row in the diagram.
 * If you want to hide the replaced row after expanding the collapsible, use icon as empty filler as in example 4.2.
 * In any case, mind to provide a sufficient text-width. Here, using text-width=120 would break the alignment of the icons.
 * Collapsible elements are intentionally disabled in mobile view, so the replaced row will never be visible. Keep this in mind while creating a diagram.

Dual text sidebar
For larger and more complicated diagrams, it often helps to have a text sidebar on the left as well as the right.

or


 * Left text cells require "exclamation mark-space-exclamation mark" separating them from icon cells.
 * If there is no "tilde-tilde" (
 * 3 values, separated by commas:
 * 6 values:
 * If the number of values is not equal to 1, 3 or 6, the entire parameter will be ignored.
 * If the text width of right-right remark is smaller than needed, its width definition can be omitted, as in example 6.1.
 * If a specific text cell is not used anywhere on the map, that width definition can be omitted, as in example 6.2.
 * Define the general table width with the parameter if  alone cannot prevent a break.
 * If the empty icon cell of the collapsible row is being squashed, use empty icon to correct the icon columns.

Conversion policies
Many contributors of the English Route Diagram Template project during the implementation of Routemap have conflicting opinions about the justification of replacing all maps of legacy BS row templates by the Lua-based Routemap. Opponents deem the map markups of Routemap to be too esoteric for editors unfamiliar with Routemap markup to modify. While proponents support a complete conversion for better performance. There is no consensus reached at the moment so any transition without massively updating the map appearance for reflecting service and/or structural change in reality should only be done with the following considerations:
 * The map of the legacy BS row template design has exceeded template size limit in the transcluding page, which means the template does not expand into its intended appearance but only the link to the template page is shown, so there is an imminent need to translate the map into Routemap design to reduce post-expand include size.
 * If there is no template size issue, respect the preference of the initial contributor of the first completed version of the diagram. If that contributor contests the change to Routemap, retain the BS row template design.

Technical options
All BS row templates have had substitutable counterparts created; hence conversion can be easily done by prepending  and appending   to every BS row template name in the map. For example, change  in the map to , then publish changes; it will produce. The process can be sped up by using the "replace all" function of advanced edit tool or separate text editor such as Notepad or Notepad++, but the search rule for the BS row templates should ideally be a regular expression, like  → , in order to avoid templates with similar names such as BSto and BSsplit in case they are present in the map.

"Column mode editing" can avoid the trouble of find and replace to add  on all rows efficiently. This function is common in advanced text editors like Geany, Notepad++ and Sublime Text.

You can also use the "convertbs" function of Module:Routemap.

Function convertbs
Copy and paste the following code to any edit area of this wiki, maybe the map page you are working on:

Then copy and paste the original BS-map or BS-table map code between the  tags (alternatively paste the invoke convertbs header before the original map code and the   ending after the map code) and show preview. It will generate the safesubst version and show the original versions (for comparison) of the map code. You copy the safesubst code from the preview area back to the edit area, and you should remove everything of  if the preview of the new code works properly.

On the English Wikipedia, the template {{subst:convertbs}} can be used as a shortcut:

If it doesn't work, it's possible that you haven't copied some of the relevant code, such as table markup for BS-table diagrams, or that you've copied code which actually belongs to something else.

Embedding into infobox

 * Use to remove title bar and table border. If creating a separate template which will be embedded into an infobox, wrap inline=1 in  tags. Also  is helpful to locate the Navbar better.

Template data
{	"description": "Template for displaying diagram composed of icon images and text labels in uniform style.", "params": { "inline": { "label": "Inline state", "type": "string", "required": false, "description": "Remove title bar and border for transclusion in infobox" },		"title": { "label": "Table title", "type": "string", "required": false, "description": "Official title of the system. Value «no» will remove the table title row, but this will also disable the table collapsible switch as well" },		"title color": { "label": "Title font color", "type": "string", "required": false, "default": "#FFF or #252525; depends", "description": "Color of the title's text; automatically black or white to contrast with the title background color. Only use colors that contrast well with the background color", "aliases": [ "title-color" ]		},		"title bg color": { "label": "Title background color", "type": "string", "required": false, "default": "#27404E", "description": "Background color of the title", "aliases": [ "title-bg" ]		},		"collapsible": { "label": "Collapsibility", "type": "string", "required": false, "description": "Whether the whole infobox is collapsible or not" },		"collapse": { "label": "Collapsing state", "type": "string", "required": false, "description": "Collapsing state. Shown by default. Any value will make the table collapse by default", "aliases": [ "collapsed" ]		},		"navbar": { "label": "Template name for Navbar", "type": "string", "required": false, "description": "This must exactly match the diagram template page name so the Navbar template will appear and link to the template page", "aliases": [ "tnavbar" ]		},		"navbar pos": { "label": "Position of the Navbar", "type": "string", "required": false, "description": "Position of the Navbar template. Float to left in the title bar by default; «1» for top-right corner of the map (just under the title bar); «2» for the middle bottom of the map" },		"legend": { "label": "Legend appearance", "type": "wiki-page-name", "required": false, "default": "Template:Railway line legend", "description": "Alias of the legend link. It can be «bus», «canal», «footpath» or «track». «0» or «no» for no legend at all" },		"legend alt": { "label": "Legend link text", "type": "string", "required": false, "default": "Legend", "description": "Different link name in place of «Legend» if desirable" },		"float": { "label": "Floating state", "type": "string", "required": false, "default": "right", "description": "Floating state of the whole box: «right» by default; optionally «left» or «none»" },		"bg": { "label": "Background color", "type": "string", "required": false, "default": "#F9F9F9", "description": "Background color of the whole map area" },		"style": { "label": "CSS style values", "type": "string", "required": false, "description": "Additional CSS style definition of the whole infobox" },		"top": { "label": "Top note", "type": "string", "required": false, "description": "Space for optional note or infobox above the map", "aliases": [ "on top" ]		},		"footnote": { "label": "Bottom note", "type": "string", "required": false, "description": "Space for optional note or infobox below the map", "aliases": [ "bottom" ]		},		"text-width": { "label": "Width of map text cell", "type": "string", "required": false, "description": "Extend the width of the map text cell so the collapsible section within the map does not break", "aliases": [ "tw" ]		},		"map": { "label": "Map markups", "description": "Map data which uses specific markup/separators to load icon image and arrange the text in the uniform style", "required": true, "type": "string", "aliases": [ "1"			]		},		"navbar mini": { "label": "Small navbar", "description": "If the navbar is not in default position, then this changes whether the navbar displays as \"V · T · E\" (default for navbar pos 1; values: «1», «y», «yes», «true») or \"This diagram: view · talk · edit\" (default for navbar pos 2; values: «0», «n», «no», «false»).", "type": "string" }	},	"format": "block", "paramOrder": [ "inline", "title", "title color", "title bg color", "collapsible", "collapse", "navbar", "navbar pos", "navbar mini", "legend", "legend alt", "float", "bg", "style", "top", "footnote", "text-width", "map" ] }