Template:Format link/sandbox
| This is the template sandbox page for Template:Format link (diff). |
| This template is used on approximately 4,700 pages and changes may be widely noticed. Test changes in the template's /sandbox or /testcases subpages, or in your own user subpage. Consider discussing changes on the talk page before implementing them. |
| This template uses Lua: |
This template formats a link for use in hatnote templates. It accepts up to three positional parameters, the link, an optional display value, and an optional target override (which if provided, makes the link parameter optional). These parameters may also be supplied by name, as link, display, and target respectively. Links to categories and files are automatically escaped with the colon trick, and links to sections are automatically formatted as page § section, rather than the MediaWiki default of page#section.
Usage
[edit]Link only:
{{format link|link}}
Link plus display:
{{format link|link|display}}
Link with an italicized page name:
{{format link|link|italicizepage=yes}}
Link with an italicized section name:
{{format link|link|italicizesection=yes}}
If the link or display values contain an equals sign, you will need to specify the parameter names like this:
{{format link|1=link|2=display}}
Link with a target override:
{{format link|link|display|target}}
Link with parameters supplied by name:
{{format link|link=link|display=display|target=target}}
Examples
[edit]{{format link|Lion}}→ [[Lion]] → Lion{{format link|Lion#Etymology}}→ [[Lion#Etymology|Lion § Etymology]] → Lion § Etymology{{format link|Category:Lions}}→ [[:Category:Lions]] → Category:Lions{{format link|Lion#Etymology|Etymology of lion}}→ [[Lion#Etymology|Etymology of lion]] → Etymology of lion{{format link|#Bar|Foo#Bar}}→ [[:Foo#Bar|§ Bar]] → § Bar{{format link|Quo warranto#Philippines|italicizepage=true}}→ [[Quo warranto#Philippines|<i>Quo warranto</i> § Philippines]] → Quo warranto § Philippines{{format link|Cybercrime Prevention Act of 2012#Disini v. Secretary of Justice|italicizesection=true}}→ [[Cybercrime Prevention Act of 2012#Disini v. Secretary of Justice|Cybercrime Prevention Act of 2012 § <i>Disini v. Secretary of Justice</i>]] → Cybercrime Prevention Act of 2012 § Disini v. Secretary of Justice{{format link}}→ Error: no link or target specified! (help)
Errors
[edit]If this template is used and neither the link parameter (or positional parameter 1) nor the target parameter (or positional parameter 3) is supplied, then the template will return an error message. At least one of those must be supplied.
See also
[edit]- {{Format linkr}} – an arguably better version of this template which converts underscores to spaces and calls {{urldecode}} on the input
- {{Section link}}
- {{formatter link}} – a template for applying a Wikidata formatter URL (P1630)
TemplateData
[edit]TemplateData for Format link
This template simplifies the process of formatting links from the URL bar by automatically replacing underscores with spaces and decoding URL-encoded parts.
| Parameter | Description | Type | Status | |
|---|---|---|---|---|
| Page | 1 link | The name of the page the link points to. It can include a section after a hashtag (#).
| String | required |
| Display | 2 display | optional display value
| String | optional |
| Target | 3 target | optional target override (which if provided, makes the link parameter optional)
| String | optional |
| Italicize page | italicizepage | Set to 'y' to italicize the page name.
| String | optional |
| No URL Decode | nud | Set to 'y' to prevent URL decoding, while still replacing underscores with spaces.
| String | optional |
| keepunderscore | keepunderscore | no description | Unknown | deprecated |