Difference between revisions of "Template:PipeTrick"
(Created page with "<noinclude> This template creates a link that uses the pipe trick if and only if the pipe trick can be used. i.e., the pipe trick is valid to be used for a link such as [[XCS...") |
(removing #es) |
||
Line 9: | Line 9: | ||
Since we can't always tell in templates whether a pipe trick is needed, this template can be called instead, to determine whether the pipe trick is possible, and produce a link with the pipe trick if it is, or without the pipe trick if attempting the pipe trick would break the link. | Since we can't always tell in templates whether a pipe trick is needed, this template can be called instead, to determine whether the pipe trick is possible, and produce a link with the pipe trick if it is, or without the pipe trick if attempting the pipe trick would break the link. | ||
− | </noinclude>{{#arraydefine:colonTest|{{{ | + | </noinclude>{{#arraydefine:colonTest|{{{1|}}}|:}}{{#arraydefine:openParenTest|{{{1|}}}|(}}{{#arraydefine:closeParenTest|{{#arrayindex:openParenTest|1}}|)}}{{#switch:{{arraysize:colonTest}}| 0= {{#switch:{{#arraysize:closeParenTest}}|0 = [[{{{1}}}]]| #default= [[{{{1}}}{{!}}]]}} | #default = [[{{{1}}}{{!}}]]}} |
Revision as of 14:47, 12 May 2014
This template creates a link that uses the pipe trick if and only if the pipe trick can be used.
i.e., the pipe trick is valid to be used for a link such as XCSG:Node, producing Node because the article is in a namespace.
Similarly, the pipe trick is valid to be used for a link such as DataFlow (Node), producing DataFlow, because that page has a parenthetical disambiguation.
However, the pipe trick will not work for a link that does not have anything to remove, such as Node, and adding a pipe will break the link, giving Node.
Since we can't always tell in templates whether a pipe trick is needed, this template can be called instead, to determine whether the pipe trick is possible, and produce a link with the pipe trick if it is, or without the pipe trick if attempting the pipe trick would break the link. [[{{{1}}}|]]