今天是2024年8月23日 第34周 星期五
代人,时大变了。
我们生活在大地上,但我们的梦想超越天空。
「Template:IncludeAt」修訂間的差異
enmgp>公的驱逐舰 小 |
|||
(未顯示由 2 位使用者於中間所作的 9 次修訂) | |||
行 1: | 行 1: | ||
<includeonly>{{#ifeq:<!-- | <includeonly>{{#ifeq:<!-- | ||
− | if noinclude=true, disable entirely | + | //if noinclude=true, disable entirely |
-->{{lc:{{{noinclude|}}}}}|true||<!-- | -->{{lc:{{{noinclude|}}}}}|true||<!-- | ||
− | + | //Store NAMESPACENUMBER. if demospaceid exists and is legal, use demospaceid instead | |
− | -->{{#vardefine:nsid|{{# | + | -->{{#vardefine:nsid|{{#iferror:{{#expr:{{{demospaceid|error}}}*0}}|{{NAMESPACENUMBER}}|{{#expr:trunc {{{demospaceid}}}}} }} }}<!-- |
− | + | //Start checking for namespace | |
− | chk:ANY Talk page | + | //chk:ANY Talk page if "anytalk" is defined |
− | -->{{#ifeq:{{#expr:{{#var: | + | -->{{#ifeq:{{#ifeq:{{{anytalk}}}|{{{anytalk|}}}|{{#expr:{{#var:nsid}}mod2}}|2}}|1|{{{anytalk}}}|<!-- |
− | -->{{#switch:{{#var:nsid}}<!-- | + | -->{{#switch:{{#var:nsid}}<!-- |
− | chk:(MAIN) | + | //chk:(MAIN) if "main" is defined |
− | -->| 0 = {{{main | + | -->| 0{{#ifeq:{{{main}}}|{{{main|}}}||NULL}}= {{{main}}}<!-- |
− | chk:User | + | //chk:User if "user" is defined |
− | -->| 2 = {{{user|}}}<!-- | + | -->| 2{{#ifeq:{{{user}}}|{{{user|}}}||NULL}}= {{{user}}}<!-- |
− | chk: | + | //chk:Project if "project" is defined |
− | chk:MediaWiki: | + | -->| 4{{#ifeq:{{{project}}}|{{{project|}}}||NULL}}= {{{project}}}<!-- |
− | chk:Template | + | //chk:File if "file" is defined |
− | -->|10 = {{{template | + | -->| 6{{#ifeq:{{{file}}}|{{{file|}}}||NULL}}= {{{file}}}<!-- |
− | chk:Help | + | //chk:MediaWiki if "mediawiki" is defined |
− | -->|12 = {{{help | + | -->| 8{{#ifeq:{{{mediawiki}}}|{{{mediawiki|}}}||NULL}}= {{{mediawiki}}}<!-- |
− | chk:Category | + | //chk:Template if "template" is defined |
− | -->|14 = {{{category | + | -->|10{{#ifeq:{{{template}}}|{{{template|}}}||NULL}}= {{{template}}}<!-- |
− | does not yet include Modules | + | //chk:Help if "help" is defined |
− | -->|#default = {{#switch:{{FULLPAGENAME}}<!-- | + | -->|12{{#ifeq:{{{help}}}|{{{help|}}}||NULL}}= {{{help}}}<!-- |
− | check for FULL page name. Allow | + | //chk:Category if "category" is defined |
− | -->|{{{pagename|}}} = {{{page|}}}<!-- | + | -->|14{{#ifeq:{{{category}}}|{{{category|}}}||NULL}}= {{{category}}}<!-- |
− | -->|{{{pagename2|}}} = {{{page2|}}}<!-- | + | //does not yet include Modules, etc. since they are not built in |
− | -->|{{{pagename3|}}} = {{{page3|}}}|#default={{{other|}}}}}}}}}}}</includeonly><noinclude>{{doc}}</noinclude> | + | -->|#default =<!-- |
+ | -->{{#switch:{{FULLPAGENAME}}<!-- | ||
+ | //check for FULL page name. Ignore entire entry if corresponding pagename is not defined. | ||
+ | //Allow 3 entries, but more can be added if there is the need. | ||
+ | -->|{{{pagename}}}{{#ifeq:{{{pagename}}}|{{{pagename|}}}||NULLPAGENEVERCHECK}}= {{{page|}}}<!-- | ||
+ | -->|{{{pagename2}}}{{#ifeq:{{{pagename2}}}|{{{pagename2|}}}||NULLPAGENEVERCHECK}}= {{{page2|}}}<!-- | ||
+ | -->|{{{pagename3}}}{{#ifeq:{{{pagename3}}}|{{{pagename3|}}}||NULLPAGENEVERCHECK}}= {{{page3|}}}<!-- | ||
+ | //done checking everything and there was no match. Use "other". | ||
+ | -->|#default={{{other|}}}<!-- | ||
+ | -->}}<!-- | ||
+ | -->}}<!-- | ||
+ | -->}}<!-- | ||
+ | -->}}</includeonly><noinclude>{{doc}}<!-- | ||
+ | //C++ & C# best programmer waifus (滑稽 | ||
+ | --></noinclude> |
於 2020年6月8日 (一) 00:27 的最新修訂
![]() | 本模板原先來自英文萌娘百科的Template:IncludeAt,依照 CC BY-SA 3.0 授權被引入;原始貢獻者的名字可以在這裡看到。 經過雙方編輯者的修改,本模板可能已與它的來源大不相同。 | ![]() |
Template Data
Meta template for including different information according to the namespace or the page they are included in. Common usage includes category management (e.g. do not include document page (where examples are given) into categories).
參數 | 描述 | 類型 | 狀態 | |
---|---|---|---|---|
Anytalk | anytalk | Information to be included at any talkpage. | 字串 | 選填 |
Main | main | Information to be included at (main) namespaces. | 字串 | 選填 |
User | user | Information to be included at User namespaces. | 字串 | 選填 |
Project | project | Information to be included at Project namespaces. | 字串 | 選填 |
File | file | 沒有描述 | 不明 | 選填 |
Mediawiki | mediawiki | 沒有描述 | 不明 | 選填 |
Template | template | Information to be included at Template namespaces. | 字串 | 選填 |
Help | help | Information to be included at Help namespaces. | 字串 | 選填 |
Category | category | Information to be included at Category namespaces. | 字串 | 選填 |
Pagename | pagename | The FULL name of a page. | 字串 | 選填 |
Page | page | Information to be included at "pagename". | 字串 | 選填 |
Pagename2 | pagename2 | The FULL name of a page. | 字串 | 選填 |
Page2 | page2 | Information to be included at "pagename2". | 字串 | 選填 |
Pagename3 | pagename3 | The FULL name of a page. | 字串 | 選填 |
Page3 | page3 | Information to be included at "pagename3". | 字串 | 選填 |
Other | other | Information to be included at any pages not matching any defined selections. | 字串 | 建議 |
Don't include | noinclude | If this argument is "true" (the word ONLY, case insensitive), then nothing will be included, even if rules are met. | 字串 | 選填 |
Demonstration Namespace ID | demospaceid | The ID of a namespace for demonstration. This "fake" ID will replace the actual namespace ID of the page the template is located on, leading it to act as if it is placed at the specified namespace. | 數值 | 選填 |
Syntax
{{IncludeAt |anytalk= |main= |user= |project= |template= |help= |category= |pagename= |page= |pagename2= |page2= |pagename3= |page3= |other= |noinclude= |demospaceid= }}
Delete unused parameters; the template sensitive to whether a parameter is defined.
Behaviour
parameters
If a parameter is defined(even if it is null or whitespaces), the template will attempt to match its case.
If a parameter is not defined, then the template will ignore that case when matching; it will usually be encompassed by the parameter other
instead.
Here are some selected behaviors of IncludeAt:
Code | Result in main namespace | Result in template namespace | Comment |
---|---|---|---|
<code>{{IncludeAt
|
main namespace
|
other namespaces
|
The template parameter is not defined, so IncludeAt disregard it during check. Only main namespace cases are checked and template namespace cases are caught by the other parameter.
|
<code>{{IncludeAt
|
main namespace
|
template namespace
|
The two cases here are both defined. IncludeAt checks and provide results in both cases. |
<code>{{IncludeAt
|
main namespace
|
(empty result)
|
Notice that both cases here are still defined: the template parameter is present but the value is an empty string. IncludeAt checks and provide results in both cases, and for template namespace cases, it faithfully reproduces the empty string.
|
<code>{{IncludeAt
|
main namespace
|
(empty result)
|
IncludeAt do not mangle with the other parameter (the default case); even if it wasn't explicitly defined, it will still catch all unmatched cases. The default value of other is an empty string.
|
<code>{{IncludeAt}}</code>
|
(empty result)
|
(empty result)
|
An IncludeAt with no defined parameters. The other parameter will always be outputted and its default is an empty string.
|
When a parameter is deemed undefined, the template adds NULL
or NULLPAGENEVERCHECK
to the comparison argument to prevent matches. This means that, in theory, if the template is placed on a page with a name like {{{pagename}}}NULLPAGENEVERCHECK
, the template will misbehave.
demospaceid
demospaceid
should be a positive integer. If it is not a number (including nonexistent), the template falls back on using the namspace number of the page it is located on; if it is a number but not an integer, the decimals are truncated by the template. You may use the magicword {{NAMESPACENUMBER:(the page you want to emulate)}}
or refer to the MediaWiki Manual to obtain the namespace number you need.
上述文件嵌入自Template:IncludeAt/doc。 (編輯 | 歷史) 編者可以在本模板的沙盒 (建立 | 鏡像)和測試樣例 (建立)頁面進行實驗。 請在/doc子頁面中添加分類。本模板的子頁面。 |