This wiki is a XML full dump clone of "Heroes Wiki", the main wiki about the Heroes saga that has been shut down permanently since June 1, 2020. The purpose of this wiki is to keep online an exhaustive and accurate database about the franchise.

Template:Delink: Difference between revisions

From Heroes Wiki
Jump to navigation Jump to search
Content deleted Content added
imported>MiamiVolts
add extra sub to remove trailing space
imported>MiamiVolts
undo, remove linebreak instead
 
Line 1: Line 1:
<includeonly>{{#sub:{{#if:{{{noprecede|}}}|<!--no preceding-->{{#sub:{{#ifeq:{{#sub:{{{linktext}}}|0|2}}|{{#sub:[[&nbsp;]]|0|2}}|{{#ifeq:{{#sub:{{{linktext}}}|{{#len:{{{linktext}}}}}|1}}|{{#sub:[[&nbsp;]]|10|1}}<!-- The ]] of a link is a single wiki character -->|{{#sub:{{{linktext}}}|{{#ifeq:{{#pos:{{{linktext}}}|{{pipe}}}}||{{#ifeq:{{#sub:{{{linktext}}}|2|6}}|:Image|2|1}}<!-- Image links are preceded with the : character -->|{{#pos:{{{linktext}}}|{{pipe}}}}}}|-2}}|{{{nolink|X}}}{{{linktext}}}}}|{{{nolink|X}}}{{{linktext}}}}}|1}}|<!--with preceding-->{{#ifeq:{{#sub:{{{linktext}}}|0|2}}|{{#sub:[[&nbsp;]]|0|2}}|{{#ifeq:{{#sub:{{{linktext}}}|{{#len:{{{linktext}}}}}|1}}|{{#sub:[[&nbsp;]]|10|1}}<!-- The ]] of a link is a single wiki character -->|{{#sub:{{{linktext}}}|{{#ifeq:{{#pos:{{{linktext}}}|{{pipe}}}}||{{#ifeq:{{#sub:{{{linktext}}}|2|6}}|:Image|2|1}}<!-- Image links are preceded with the : character -->|{{#pos:{{{linktext}}}|{{pipe}}}}}}|-2}}|{{{nolink|X}}}{{{linktext}}}}}|{{{nolink|X}}}{{{linktext}}}}}}}|0}}</includeonly>
<includeonly>{{#if:{{{noprecede|}}}|<!--no preceding-->{{#sub:{{#ifeq:{{#sub:{{{linktext}}}|0|2}}|{{#sub:[[&nbsp;]]|0|2}}|{{#ifeq:{{#sub:{{{linktext}}}|{{#len:{{{linktext}}}}}|1}}|{{#sub:[[&nbsp;]]|10|1}}<!-- The ]] of a link is a single wiki character -->|{{#sub:{{{linktext}}}|{{#ifeq:{{#pos:{{{linktext}}}|{{pipe}}}}||{{#ifeq:{{#sub:{{{linktext}}}|2|6}}|:Image|2|1}}<!-- Image links are preceded with the : character -->|{{#pos:{{{linktext}}}|{{pipe}}}}}}|-2}}|{{{nolink|X}}}{{{linktext}}}}}|{{{nolink|X}}}{{{linktext}}}}}|1}}|<!--with preceding-->{{#ifeq:{{#sub:{{{linktext}}}|0|2}}|{{#sub:[[&nbsp;]]|0|2}}|{{#ifeq:{{#sub:{{{linktext}}}|{{#len:{{{linktext}}}}}|1}}|{{#sub:[[&nbsp;]]|10|1}}<!-- The ]] of a link is a single wiki character -->|{{#sub:{{{linktext}}}|{{#ifeq:{{#pos:{{{linktext}}}|{{pipe}}}}||{{#ifeq:{{#sub:{{{linktext}}}|2|6}}|:Image|2|1}}<!-- Image links are preceded with the : character -->|{{#pos:{{{linktext}}}|{{pipe}}}}}}|-2}}|{{{nolink|X}}}{{{linktext}}}}}|{{{nolink|X}}}{{{linktext}}}}}}}</includeonly><noinclude>
<noinclude>
== Usage ==
== Usage ==
<pre>{{Delink
<pre>{{Delink

Latest revision as of 00:07, 15 January 2008

Usage

{{Delink
  |linktext=<string with link in it>
  |nolink=<Optional character(s) to precede string if it didn't contain a link to begin with;
           default is the X character>
  |noprecede=<Optional; set true to trim off the first character>
}}

This template returns the string inside a link preceded by [ or |; or the original string preceded by X or the specified "nolink" character(s), if not a link.

Notes

  • If the link destination is different from the shown text, only the shown text is returned.
  • The nolink option is useful to combine with an external sub call to trim whitespace. If a link is passed, the output will be preceded with the [ or | character depending on whether or not it is a piped link.
  • This template only delinks if the link occupies the entire string (beginning to end).