Template talk:Wikilink
From Wikipedia, the free encyclopedia
[edit] Documentation
[edit] Usage
- {{wikilink|Article|Label}}
- Article: Name of Wikipedia article to link to. If omitted the second parameter is used as also being the article.
- Label: Text label of wikilink.
The second parameter has to be specified, the first is optional.
This template was created for use within templates due to behavior of bracket and pipe characters. Everywhere else, use normal wikilink syntax instead:
- [[Article|Label]]
[edit] Tests
Testing using various parameters. Some tests are expected to fail (the minus signs work as markers to check that no wrong space chars are produced):
-{{wikilink|a|b}}-
gives -b--{{wikilink|2=b}}-
gives -b--{{wikilink||b}}-
gives -b-- Errors expected:
-{{wikilink|a|}}-
gives -[[a|]]--{{wikilink||}}-
gives -[[|]]--{{wikilink|a}}-
gives -{{{2}}}--{{wikilink|}}-
gives -[[{{{2}}}|{{{2}}}]]--{{wikilink}}-
gives -[[{{{2}}}|{{{2}}}]]-
Contents |
[edit] Discussion
[edit] Proposed change of behavior
I don't think there is any benefit to having the second parameter be mandatory. I think a better behavior is as follows:
- The first parameter, the article name, is optional, but if it is missing, the template returns the label text without a link.
- The second parameter, the label, is optional, but if it is missing, the template returns a simple non-piped link to the article name.
- If no parameters are present, the template returns nothing.
An appropriate template would be the following:
{{if |1={{{1|}}} |2=[[{{{1}}}{{if |1={{{2|}}} |2=<nowiki>|</nowiki>{{{2}}} }}]] |3={{{2|}}} }}
Thus, {{wikilink|foo}}
returns [[foo]]
, but {{wikilink||foo}}
returns foo
. COGDEN 20:46, 23 November 2005 (UTC)
[edit] WP:AUM
Aren't we supposed to avoid templates within templates? --Angr (tɔk) 15:48, 10 January 2006 (UTC)
- Yes, but the parser sometimes can not identify a wikilink within a template so this incantation is needed to provide a hint and produce the link. Basically, try not using this but if a template can't produce a wikilink then try this. (SEWilco 16:40, 10 January 2006 (UTC))
- It's been a while since I had to use this, but I think it is needed when a template has to emit a wikilink which contains a piped label. The parser can't identify that the pipe symbol belongs to the wikilink and the pipe gets swallowed as being a delimiter for a template parameter. But another template (wikilink) can be invoked, pass the desired link terms, and this template emits the Wiki link. (SEWilco 04:22, 11 January 2006 (UTC))
- That's not it. I've tested (see last test at User_talk:Gracefool/cite_book#tests) and can't get piped links, or any links, to fail. If we can't work out why it's needed, surely we should get rid of this template, reducing server load while making templates easier to read? ··gracefool |☺ 12:17, 16 February 2006 (UTC)
- Ah, it must be so you can pass fields which include the square bracket characters. I don't see why it would be necessary do that — after all, there are other characters like curly braces and pipes which never work. ··gracefool |☺ 12:24, 16 February 2006 (UTC)
No. AUM has been deprecated and rejected. Ignore all references to it. John Reid 02:18, 9 May 2006 (UTC)