Template:Wikipedia link

From Soul's Remnant Wiki
Revision as of 23:20, 28 October 2025 by Guninvalid (talk | contribs) (this took a slightly embarassing amount of time)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


Some test links: Souls (on Wikipedia) Jel (on Wikipedia)

Template:Documentation top

This template took a slightly embarassing amount of time to make but it's pretty easy to explain:

{{wl|Source text|Wikilink}} {{wl|Example}}

Renders as:

Source text (on Wikipedia) Example (on Wikipedia)

with (on wikipedia) linking to wikipedia:Wikilink in the first case, and wikipedia:Example in the second case.

How it works (the headache inducing code)

The exact code under the hood is actually pretty simple but it's still a mess of symbols. But I can summarize it here.

The <includeonly> tags allow me to isolate the template to only the relevant section, and leave the rest under <noinclude> so it doesn't bother the rest of the template. So we only focus on the bit inside:

Start with {{{1}}}, which simply parrots back the first field, in these example case, "Source Text" and "Example".

Next, the <small> small tag indicates that the tag should be in small text.

Next, we open a link with [[wikipedia:, indicating that we would like to make a cross-wiki link to an article on Wikipedia.

Next, we use the {{#if {{{2|}}}| block to test if the second field exists. If it does, we link to the second field. In the first case, this means we resolve the link to Wikilink, which we do with the second component: {{{2}}}. If it does not exist, we assume that the link is the same in both places, so we simply link the link text, using {{{1}}}.

Finally, we use }} to close out the if block, ]] to close out the link, ) to close out the visible parentheses, </small> to close out the small text block, and </includeonly> to indicate the end of the relevant section.

Template:Documentation bottom