Template:URL2
| This template is used on approximately 21,000 pages and changes may be widely noticed. Test changes in the template's /sandbox or /testcases subpages, or in your own user subpage. Consider discussing changes on the talk page before implementing them. |
| This template uses Lua: |
This is a fork of Template:URL for use in infoboxes.
It behaves similarly to {{URL}} with the following exceptions:
- By default it does not display anything if the parameters are blank or omitted. Template:URL displays
{{URL|example.com|optional display text}}by default. - It implements a parameter
|msg=that turns on or off the message{{URL|example.com|optional display text}}. Setting msg to false or anything beginning with n or N will suppress the message. Anything else enables the message. - It strips html tags and wiki-link markup from the supplied url parameter.
- It truncates the url parameter at the first space it finds.
- It can take its own output as input, allowing website parameters to be wrapped in
{{URL2}}in the design of an infobox, without causing problems if editors add|website={{URL|some.url.com}}in an article.
Usage
{{URL2|url}}{{URL2|1=url}}
Examples
Different from Template:URL
If there is no input, the default behavior of URL2 is to display nothing (use |msg= to display the instructional message):
{{URL2| }}→
{{URL2|msg=yes| }}→{{URL|example.com|optional display text}}<code>{{[[Template:URL|URL]]|''example.com''|''optional display text''}}</code>
{{URL2|msg=true| }}→{{URL|example.com|optional display text}}<code>{{[[Template:URL|URL]]|''example.com''|''optional display text''}}</code>
URL2 handles formatting commonly found in the |website= parameter of an infobox:
{{URL2|[http://www.example.com]}}→ www.example .com <span class="url">[http://www.example.com www<wbr/>.example<wbr/>.com]</span>
{{URL2|http://www.example.com|website}}→ website<span class="url">[http://www.example.com website]</span>
{{URL2|{{URL|www.example.com}}}}→ www.example .com <span class="url">[http://www.example.com www<wbr/>.example<wbr/>.com]</span>
{{URL2|{{URL2|www.example.com}}}}→ www.example .com <span class="url">[http://www.example.com www<wbr/>.example<wbr/>.com]</span>
Same as Template:URL
The template wraps the output in <span class="url">...</span> (see § Microformat) and adds <wbr/> before displayed periods:
{{URL2|www.example.com}}→ www.example .com <span class="url">[http://www.example.com www<wbr/>.example<wbr/>.com]</span>
The use of http://, https://, a protocol-relative URL, or a different protocol is preserved in the URL but is not shown in the link text:
{{URL2|http://www.example.com}}→ www.example .com <span class="url">[http://www.example.com www<wbr/>.example<wbr/>.com]</span>
{{URL2|https://www.example.com}}→ www.example .com <span class="url">[https://www.example.com www<wbr/>.example<wbr/>.com]</span>
{{URL2|//www.example.com}}→ www.example .com <span class="url">[//www.example.com www<wbr/>.example<wbr/>.com]</span>
{{URL2|ftp://ftp.example.com}}→ ftp.example .com <span class="url">[ftp://ftp.example.com ftp<wbr/>.example<wbr/>.com]</span>
If the path is only a slash (/) it is not displayed in the link text:
{{URL2|https://www.example.com/}}→ www.example .com <span class="url">[https://www.example.com/ www<wbr/>.example<wbr/>.com]</span>
The template also adds <wbr/> before any displayed slashes (/) in the path:
{{URL2|https://www.example.com/path}}→ www.example .com /path <span class="url">[https://www.example.com/path www<wbr/>.example<wbr/>.com<wbr/>/path]</span>
For a URL containing an equal sign (=), use |1=:
{{URL2|1=http://www.example.com/path?section=17}}→ www.example .com /path?section=17 <span class="url">[http://www.example.com/path?section=17 www<wbr/>.example<wbr/>.com<wbr/>/path?section=17]</span>
Microformat
The template wraps the displayed URL with class="url" so that it is included in any parent microformat which takes a URL parameter - see Wikipedia:WikiProject Microformats.
See also
- {{URL}}
- {{#invoke:WikidataIB|url2}}
- {{Official URL}}
- {{Official website}}
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.