defzone.net@gmail.comLiên hệ
DZ
DefZone.Net

Kien thuc cong nghe & giai tri

Bai vietDia diemAlbum anhGameCua hang
  1. Home
  2. Wiki
Template documentation[view] [edit] [history] [purge]
WarningThis template is used on approximately 20,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:
  • Module:URL (sandbox)

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

[edit]
  • {{URL2|url}}
  • {{URL2|1=url}}

Examples

[edit]

Different from Template:URL

[edit]

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>&#123;&#123;[[Template:URL|URL]]&#124;''example.com''&#124;''optional display text''&#125;&#125;</code>
  • {{URL2|msg=true| }} → {{URL|example.com|optional display text}}
    <code>&#123;&#123;[[Template:URL|URL]]&#124;''example.com''&#124;''optional display text''&#125;&#125;</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

[edit]

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

[edit]

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

[edit]
  • {{URL}}
  • {{#invoke:WikidataIB|url2}}
  • {{Official URL}}
  • {{Official website}}
The above documentation is transcluded from Template:URL2/doc. (edit | history)
Editors can experiment in this template's sandbox (edit | diff) and testcases (create) pages.
Add categories to the /doc subpage. Subpages of this template.
DZ
DefZone.Net

Noi chia se kien thuc, huong dan va kham pha cong nghe.

Lien ket nhanh

Trang chủBài viếtWikiCửa hàngLiên hệ

Liên hệ

Email: defzone.net@gmail.com
Điện thoại: +84 762 559 696
Địa chỉ: Thiên Hương, Thủy Nguyên, Hải Phòng

Đăng ký nhận tin

Nhận bài viết và cập nhật mới nhất qua email.

© 2025 DefZone.Net. All rights reserved.
PrivacyTermsSitemap