<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://70.231.62.181/index.php?action=history&amp;feed=atom&amp;title=Module%3ARoad_data%2Fparser%2Fhooks%2Fdoc</id>
	<title>Module:Road data/parser/hooks/doc - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://70.231.62.181/index.php?action=history&amp;feed=atom&amp;title=Module%3ARoad_data%2Fparser%2Fhooks%2Fdoc"/>
	<link rel="alternate" type="text/html" href="http://70.231.62.181/index.php?title=Module:Road_data/parser/hooks/doc&amp;action=history"/>
	<updated>2026-04-21T00:12:46Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>http://70.231.62.181/index.php?title=Module:Road_data/parser/hooks/doc&amp;diff=19819230&amp;oldid=prev</id>
		<title>imported&gt;BrandonXLF: Remove {{documentation subpage}}</title>
		<link rel="alternate" type="text/html" href="http://70.231.62.181/index.php?title=Module:Road_data/parser/hooks/doc&amp;diff=19819230&amp;oldid=prev"/>
		<updated>2024-08-15T22:43:05Z</updated>

		<summary type="html">&lt;p&gt;Remove {{documentation subpage}}&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Previous revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 22:43, 15 August 2024&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>imported&gt;BrandonXLF</name></author>
	</entry>
	<entry>
		<id>http://70.231.62.181/index.php?title=Module:Road_data/parser/hooks/doc&amp;diff=19819229&amp;oldid=prev</id>
		<title>imported&gt;BrandonXLF: Remove {{documentation subpage}}</title>
		<link rel="alternate" type="text/html" href="http://70.231.62.181/index.php?title=Module:Road_data/parser/hooks/doc&amp;diff=19819229&amp;oldid=prev"/>
		<updated>2024-08-15T22:43:05Z</updated>

		<summary type="html">&lt;p&gt;Remove {{documentation subpage}}&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Module rating|protected}}&lt;br /&gt;
{{High-use}}&lt;br /&gt;
&lt;br /&gt;
This module includes hook functions that provide extra functionality to [[Module:Road data/parser]] and its associated string modules.&lt;br /&gt;
&lt;br /&gt;
==Basics==&lt;br /&gt;
Each hook is simply a function stored in the &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt; package table exported by this module. Each function accepts two arguments:&lt;br /&gt;
* &amp;lt;code&amp;gt;parameters&amp;lt;/code&amp;gt;: The table in the string module that references the hook. In this example, this argument would be the table stored in the &amp;lt;code&amp;gt;shield&amp;lt;/code&amp;gt; field of the type table (from [[Module:Road data/strings/USA/KY]]):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
KY[&amp;quot;KY 1966&amp;quot;] = {&lt;br /&gt;
	shield = {&lt;br /&gt;
		hook = &amp;quot;split&amp;quot;,&lt;br /&gt;
		split = 100,&lt;br /&gt;
 		below = &amp;quot;Elongated circle %route%.svg&amp;quot;, &lt;br /&gt;
		above = &amp;quot;Circle sign %route%.svg&amp;quot;&lt;br /&gt;
	},&lt;br /&gt;
	link = KY.KY.link,&lt;br /&gt;
	abbr = KY.KY.abbr&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;args&amp;lt;/code&amp;gt;: The arguments originally passed to the parser.&lt;br /&gt;
&lt;br /&gt;
Hooks may modify the argument table by simply setting a new key as equal to a computed value. Modifying existing values is allowed, but discouraged.&lt;br /&gt;
&lt;br /&gt;
The return value of a hook is an ordinary format string, which may be computed within the function or pulled from the &amp;lt;code&amp;gt;parameters&amp;lt;/code&amp;gt; argument. Generally, if the hook does not compute the format string to be returned, the hook should return &amp;lt;code&amp;gt;parameters.default&amp;lt;/code&amp;gt;, which should equal a format string.&lt;br /&gt;
&lt;br /&gt;
==Hooks==&lt;br /&gt;
===&amp;lt;code&amp;gt;split&amp;lt;/code&amp;gt;===&lt;br /&gt;
This hook determines the format string to be used by the parser based on whether the route number is above or below a particular number.&lt;br /&gt;
&lt;br /&gt;
Parameters:&lt;br /&gt;
* &amp;lt;code&amp;gt;split&amp;lt;/code&amp;gt;: The number on which to split.&lt;br /&gt;
* &amp;lt;code&amp;gt;below&amp;lt;/code&amp;gt;: The format string to use if the route number is below &amp;lt;code&amp;gt;split&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &amp;lt;code&amp;gt;above&amp;lt;/code&amp;gt;: The format string to use if the route number is equal to or above &amp;lt;code&amp;gt;split&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;code&amp;gt;splitlen&amp;lt;/code&amp;gt;===&lt;br /&gt;
This hook operates in a similar fashion to &amp;lt;code&amp;gt;split&amp;lt;/code&amp;gt;, but tests the length of the route number instead of its value.&lt;br /&gt;
&lt;br /&gt;
Parameters:&lt;br /&gt;
* &amp;lt;code&amp;gt;split&amp;lt;/code&amp;gt;: The length on which to split.&lt;br /&gt;
* &amp;lt;code&amp;gt;below&amp;lt;/code&amp;gt;: The format string to use if the route number&amp;#039;s length is below &amp;lt;code&amp;gt;split&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &amp;lt;code&amp;gt;above&amp;lt;/code&amp;gt;: The format string to use if the route number&amp;#039;s length is equal to or above &amp;lt;code&amp;gt;split&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;code&amp;gt;between&amp;lt;/code&amp;gt;===&lt;br /&gt;
This hook determines the format string to be used by the parser based on whether the route number is between two given numbers.&lt;br /&gt;
&lt;br /&gt;
Parameters:&lt;br /&gt;
* &amp;lt;code&amp;gt;lower&amp;lt;/code&amp;gt;: The lower limit of the test (inclusive).&lt;br /&gt;
* &amp;lt;code&amp;gt;upper&amp;lt;/code&amp;gt;: The upper limit of the test (exclusive).&lt;br /&gt;
* &amp;lt;code&amp;gt;yes&amp;lt;/code&amp;gt;: The format string to use if the route number is between &amp;lt;code&amp;gt;lower&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;upper&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &amp;lt;code&amp;gt;no&amp;lt;/code&amp;gt;: The format string to use if the route number is not between &amp;lt;code&amp;gt;lower&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;upper&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;code&amp;gt;mask&amp;lt;/code&amp;gt;===&lt;br /&gt;
This hook adds an argument to the &amp;lt;code&amp;gt;args&amp;lt;/code&amp;gt; table based on the result of applying a supplied mask to a particular argument.&lt;br /&gt;
&lt;br /&gt;
Parameters:&lt;br /&gt;
* &amp;lt;code&amp;gt;base&amp;lt;/code&amp;gt;: The argument to be masked.&lt;br /&gt;
* &amp;lt;code&amp;gt;masked&amp;lt;/code&amp;gt;: The key used to store the mask result in the &amp;lt;code&amp;gt;args&amp;lt;/code&amp;gt; table.&lt;br /&gt;
* &amp;lt;code&amp;gt;mask&amp;lt;/code&amp;gt;: The name of the module to be used as a mask, without the &amp;quot;Module:&amp;quot; prefix. The module must return a table which maps a &amp;lt;code&amp;gt;base&amp;lt;/code&amp;gt; argument to the value stored in the &amp;lt;code&amp;gt;masked&amp;lt;/code&amp;gt; field of &amp;lt;code&amp;gt;args&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &amp;lt;code&amp;gt;default&amp;lt;/code&amp;gt;: The format string to be processed by the parser. This string may reference the argument stored in &amp;lt;code&amp;gt;args&amp;lt;/code&amp;gt; by this hook.&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;code&amp;gt;padroute&amp;lt;/code&amp;gt;===&lt;br /&gt;
This hook zero-pads the route number so that the route number has a particular number of digits.&lt;br /&gt;
&lt;br /&gt;
Parameters:&lt;br /&gt;
* &amp;lt;code&amp;gt;paddedLength&amp;lt;/code&amp;gt;: The length to which the route number should be zero-padded.&lt;br /&gt;
* &amp;lt;code&amp;gt;default&amp;lt;/code&amp;gt;: The format string to be processed by the parser. This string may reference the zero-padded route number as the &amp;lt;code&amp;gt;paddedRoute&amp;lt;/code&amp;gt; argument.&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;code&amp;gt;pagename&amp;lt;/code&amp;gt;===&lt;br /&gt;
This hook is similar to running an {{tlx|#ifeq}} to match the title of an article to a specified value in order to display certain content.  Particularly useful for images with [[WP:FUR|Fair-use rationales]].&lt;br /&gt;
&lt;br /&gt;
Parameters:&lt;br /&gt;
* &amp;lt;code&amp;gt;article&amp;lt;/code&amp;gt;: The title against which the page name is compared.&lt;br /&gt;
* &amp;lt;code&amp;gt;iftrue&amp;lt;/code&amp;gt;: The result if article and the page name match.&lt;br /&gt;
* &amp;lt;code&amp;gt;default&amp;lt;/code&amp;gt;: The result if article and the page name do not match. Defaults to &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;#039;&amp;#039;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; if not specified.&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;code&amp;gt;lowercase&amp;lt;/code&amp;gt;===&lt;br /&gt;
This hook converts the route &amp;quot;number&amp;quot; to lowercase.&lt;br /&gt;
&lt;br /&gt;
Parameters:&lt;br /&gt;
* &amp;lt;code&amp;gt;default&amp;lt;/code&amp;gt;: The format string to be processed by the parser. This string may reference the lowercased route number as the &amp;lt;code&amp;gt;lowercase&amp;lt;/code&amp;gt; argument.&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;code&amp;gt;startswith&amp;lt;/code&amp;gt;===&lt;br /&gt;
This hook determines whether a particular argument starts with any of the given patterns, and returns the value associated with the matching pattern.&lt;br /&gt;
&lt;br /&gt;
Parameters:&lt;br /&gt;
* &amp;lt;code&amp;gt;base&amp;lt;/code&amp;gt;: The argument to test.&lt;br /&gt;
* &amp;lt;code&amp;gt;startPatterns&amp;lt;/code&amp;gt;: Key-value pairs of starting patterns and the values to return if a match is found.&lt;br /&gt;
* &amp;lt;code&amp;gt;default&amp;lt;/code&amp;gt;: The value to return if no match is found.&lt;/div&gt;</summary>
		<author><name>imported&gt;BrandonXLF</name></author>
	</entry>
</feed>