Jump to content

Module:Naval Vessel Register URL/doc: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
module in beta
expand examples
Line 25: Line 25:
Examples:
Examples:
: <code><nowiki>{{#invoke:NVR|MakeShipLink|DDG_1000}}</nowiki></code> produces {{#invoke:NVR|MakeShipLink|DDG_1000}}
: <code><nowiki>{{#invoke:NVR|MakeShipLink|OLDIRON}}</nowiki></code> produces {{#invoke:NVR|MakeShipLink|OLDIRON}}
: <code><nowiki>{{#invoke:NVR|MakeShipLink|OLDIRON}}</nowiki></code> produces {{#invoke:NVR|MakeShipLink|OLDIRON}}
: <code><nowiki>{{#invoke:NVR|MakeShipLink|OLDIRON|USS ''Constitution''}}</nowiki></code> produces {{#invoke:NVR|MakeShipLink|OLDIRON|USS ''Constitution''}}
: <code><nowiki>{{#invoke:NVR|MakeShipLink|OLDIRON|USS ''Constitution''}}</nowiki></code> produces {{#invoke:NVR|MakeShipLink|OLDIRON|USS ''Constitution''}}
Line 61: Line 62:
: '''title''' — Title for link, set to <code><nowiki>''</nowiki></code> for a bare link without a title.
: '''title''' — Title for link, set to <code><nowiki>''</nowiki></code> for a bare link without a title.


Examples:
Example:
: <code><nowiki>link_string = nvr._MakeShipLink('DDG_1000', '')</nowiki></code>
: <code><nowiki>link_string = nvr._MakeShipLink('OLDIRON', '')</nowiki></code>
: <code><nowiki>link_string = nvr._MakeShipLink('OLDIRON', '')</nowiki></code>



Revision as of 01:44, 4 October 2016

{{#invoke:NVR|function}}


Summary

This module generates links to ships in the Naval Vessel Register (nvr.navy.mil) database. Intended to be used by:

The table of URL transformations used by this module can be found at Module:NVR/rules.

Using this module from templates

This function returns a link to a ship in the Naval Vessel Register.

Usage:

{{#invoke:NVR|MakeShipLink|id=|title=}}
{{#invoke:NVR|MakeShipLink}} — uses the calling template's parameters

Parameters:

1 or id — The 'file name' portion of the url path (typically the ship's hull designation) without the .HTM/.HTML extension.
2 or title — A title or label for the link.

Examples:

{{#invoke:NVR|MakeShipLink|DDG_1000}} produces Script error: No such module "NVR".
{{#invoke:NVR|MakeShipLink|OLDIRON}} produces Script error: No such module "NVR".
{{#invoke:NVR|MakeShipLink|OLDIRON|USS ''Constitution''}} produces Script error: No such module "NVR".

This function returns a link to a service ship in the Naval Vessel Register.

Usage:

{{#invoke:NVR|MakeServiceShipLink|id=|title=}}
{{#invoke:NVR|MakeServiceShipLink}} — uses the calling template's parameters

Parameters:

1 or id — The 'file name' portion of the url path (typically the ship's hull designation) without the .HTM/.HTML extension.
2 or title — A title or label for the link.

Example:

{{#invoke:NVR|MakeServiceShipLink|AFDB1_1}} produces Script error: No such module "NVR".

Using this module from Lua code

In order to use the functions in this module from another Lua module you first have to import this module.

Example:

local nvr = require('Module:NVR')

This function returns a link to a ship in the Naval Vessel Register.

Usage:

link_string = nvr._MakeShipLink(nvrid, title)

Parameters:

nvrid — The 'file name' portion of the url path (typically the ship's hull designation) without the .HTM/.HTML extension, as a string.
title — Title for link, set to '' for a bare link without a title.

Examples:

link_string = nvr._MakeShipLink('DDG_1000', '')
link_string = nvr._MakeShipLink('OLDIRON', '')

This function returns a link to a service ship in the Naval Vessel Register.

Usage:

link_string = nvr._MakeServiceShipLink(nvrid, title)

Parameters:

nvrid — The 'file name' portion of the url path (typically the ship's hull designation) without the .HTM/.HTML extension, as a string.
title — Title for link, set to '' for a bare link without a title.

Example:

link_string = nvr._MakeServiceShipLink('AFDB1_1', '')

See Also