Difference between revisions of "Template:Linked/doc"

From blackwiki
Jump to navigation Jump to search
imported>Gustronico
(testing protocol-relative links)
imported>Nardog
(→‎Usage: there are still problems, might as well use the real thing)
 
(10 intermediate revisions by 10 users not shown)
Line 1: Line 1:
 
{{Documentation subpage}}
 
{{Documentation subpage}}
<!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE -->
+
<!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) -->
 +
 
 
This template can be used to simplify the inclusion of links in templates where users may use several different forms of syntax. It accepts a parameter and returns it linked, unless it already is. Works both with wikilinks and with http links.
 
This template can be used to simplify the inclusion of links in templates where users may use several different forms of syntax. It accepts a parameter and returns it linked, unless it already is. Works both with wikilinks and with http links.
  
Line 7: Line 8:
 
This template can be substituted.
 
This template can be substituted.
 
=== Usage ===
 
=== Usage ===
; Wiki links
+
'''Wiki links'''
*{{tlx|linked|Foo}}                                           → {{linked|Foo}}
+
*<code><nowiki>{{linked|Foo}}</nowiki></code> → {{linked|Foo}}
*{{tlx|linked|Foo|Bar}}                                       → {{linked|Foo|Bar}}
+
*<code><nowiki>{{linked|Foo|Bar}}</nowiki></code> → {{linked|Foo|Bar}}
*{{tlx|linked|<nowiki>[[Foo]]</nowiki>|Bar}}                  → {{linked|[[Foo]]|Bar}}
+
*<code><nowiki>{{linked|[[Foo]]|Bar}}</nowiki></code> → {{linked|[[Foo]]|Bar}}
*{{tlx|linked|:Foo}}                                           → {{linked|:Foo}}
+
*<code><nowiki>{{linked|:Foo}}</nowiki></code> → {{linked|:Foo}}
*{{tlx|linked|File:Example.jpg}}                               → {{linked|File:Example.jpg}}
+
*<code><nowiki>{{linked|File:Example.jpg}}</nowiki></code> → {{linked|File:Example.jpg}}
*{{tlx|linked|:File:Example.jpg}}                             → {{linked|:File:Example.jpg}}
+
*<code><nowiki>{{linked|:File:Example.jpg}}</nowiki></code> → {{linked|:File:Example.jpg}}
*{{tlx|linked|Category:Food}}                                 → {{linked|Category:Food}}
+
*<code><nowiki>{{linked|Category:Food}}</nowiki></code> → {{linked|Category:Food}}
*{{tlx|linked|:Category:Food}}                                 → {{linked|:Category:Food}}
+
*<code><nowiki>{{linked|:Category:Food}}</nowiki></code> → {{linked|:Category:Food}}
 +
*<code><nowiki>{{linked|[[Category:Food]]}}</nowiki></code> → {{linked|[[Category:Food]]}}
 +
*<code><nowiki>{{linked|[[File:Example.jpg]]}}</nowiki></code> → {{linked|[[File:Example.jpg]]}}
  
;Http links
+
'''Http links'''
*{{tlx|linked|<nowiki> http://example.org</nowiki>}}          → {{linked| http://example.org}}         
+
*<code><nowiki>{{linked| http://example.org}}</nowiki></code> → {{linked| http://example.org}}         
*{{tlx|linked|<nowiki> http://example.org</nowiki>|Bar}}      → {{linked|http://example.org|Bar}}         
+
*<code><nowiki>{{linked|http://example.org|Bar}}</nowiki></code> → {{linked|http://example.org|Bar}}         
*{{tlx|linked|<nowiki> [http://example.org Foo]</nowiki>|Bar}} → {{linked|[http://example.org Foo]|Bar}}  
+
*<code><nowiki>{{linked|[http://example.org Foo]|Bar}}</nowiki></code> → {{linked|[http://example.org Foo]|Bar}}  
  
;Https links
+
'''Https links'''
*{{tlx|linked|<nowiki>https://example.org</nowiki>}}          → {{linked|https://example.org}}       
+
*<code><nowiki>{{linked|https://example.org}}</nowiki></code> → {{linked|https://example.org}}       
*{{tlx|linked|<nowiki>https://example.org</nowiki>|Bar}}      → {{linked|https://example.org|Bar}}       
+
*<code><nowiki>{{linked|https://example.org|Bar}}</nowiki></code> → {{linked|https://example.org|Bar}}       
*{{tlx|linked|<nowiki>[https://example.org Foo]</nowiki>|Bar}} → {{linked|[https://example.org Foo]|Bar}}
+
*<code><nowiki>{{linked|[https://example.org Foo]|Bar}}</nowiki></code> → {{linked|[https://example.org Foo]|Bar}}
  
;Protocol-relative // links
+
'''Protocol-relative // links'''
*{{tlx|linked|<nowiki> //example.org</nowiki>}}          → {{linked|//example.org}}         
+
*<code><nowiki>{{linked|//example.org}}</nowiki></code> → {{linked|//example.org}}         
*{{tlx|linked|<nowiki> //example.org</nowiki>|Bar}}      → {{linked|//example.org|Bar}}         
+
*<code><nowiki>{{linked|//example.org|Bar}}</nowiki></code> → {{linked|//example.org|Bar}}         
*{{tlx|linked|<nowiki> [//example.org Foo]</nowiki>|Bar}} → {{linked|[//example.org Foo]|Bar}}  
+
*<code><nowiki>{{linked|[//example.org Foo]|Bar}}</nowiki></code> → {{linked|[//example.org Foo]|Bar}}
  
 
=== See also ===
 
=== See also ===
*{{tl|Image}}
 
 
*{{tl|File title}}
 
*{{tl|File title}}
 
*{{tl|Category title}}
 
*{{tl|Category title}}
 
*{{tl|Transclude}}
 
*{{tl|Transclude}}
  
<includeonly>
+
<includeonly>{{basepage subpage|
<!-- CATEGORIES AND INTERWIKIS HERE, THANKS -->
+
<!-- Categories below this line, please; interwikis at Wikidata -->
 
[[Category:Wikipedia metatemplates]]
 
[[Category:Wikipedia metatemplates]]
 +
[[Category:Internal link templates]]
  
[[es:Plantilla:Enlazado]]
+
}}</includeonly>
</includeonly>
 

Latest revision as of 17:11, 23 November 2020

This template can be used to simplify the inclusion of links in templates where users may use several different forms of syntax. It accepts a parameter and returns it linked, unless it already is. Works both with wikilinks and with http links.

It is primarily of use in templates and should not be used in articles directly.

This template can be substituted.

Usage

Wiki links

Http links

  • {{linked| http://example.org}} → [[[:Template:Str trim]]]
  • {{linked|http://example.org|Bar}} → [[[:Template:Str trim]] Bar]
  • {{linked|[http://example.org Foo]|Bar}}Foo

Https links

  • {{linked|https://example.org}} → [[[:Template:Str trim]]]
  • {{linked|https://example.org|Bar}} → [[[:Template:Str trim]] Bar]
  • {{linked|[https://example.org Foo]|Bar}}Foo

Protocol-relative // links

  • {{linked|//example.org}}[1]
  • {{linked|//example.org|Bar}}Bar
  • {{linked|[//example.org Foo]|Bar}}Foo

See also