Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
BRUS Wikipedia
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Module:Road data/strings/doc
(section)
Module
Discussion
English
Read
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Get shortened URL
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Hooks=== Due to technical limitations, these string modules cannot contain functions. Rather than force functionality into the string framework, the parser can call functions in a separate hooks module. The functions in this module, [[Module:Road data/parser/hooks]], are more-or-less fully functional functions. The exact functionalities of these hooks are beyond the scope of this documentation. Descriptions of these hooks may be found on their documentation page. Generally speaking, a hook is called by setting the <code>hook</code> field in a table as equal to the name of a hook. Hooks receive two arguments, both tables: <code>parameters</code>, which is the table in the definition; and <code>args</code>, which is simply the table of arguments normally passed to the parser. The hook returns a string, which is then parsed as usual. A powerful feature of hooks is that they can add arbitrary values to the argument table, which may be referenced in the string returned by the hook. Generally, the format string returned by the hook is specified in some form by the <code>default</code> field of the table, though there are exceptions. Here is an example of a hook (from [[Module:Road data/strings/MEX]]): <syntaxhighlight lang="lua"> MEX.SH = { shield = { ifexists = true, arg = "state", SON = "HIGHWAYSON %route%.jpg", NLE = "Nuevo Leon State Highway %route%.PNG", default = "" }, link = { hook = "mask", mask = "Road data/masks/MEX", base = "state", masked = "fullstate", default = "%fullstate% State Highway %route%" }, abbr = "SH %route%" } </syntaxhighlight> In this example, the parser will process the link by calling the <code>mask</code> hook. In short, this hook takes the argument referenced in <code>base</code>, passes it through the mask module specified in <code>mask</code>, and stores it in the field in the arguments noted in <code>masked</code>. The hook returns the string given in <code>default</code>, which has access to the <code>fullstate</code> argument added by the hook.
Summary:
Please note that all contributions to BRUS Wikipedia may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
BRUS Wikipedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Preview page with this template