模板:If in page/doc
| File:Edit-copy green.svg | 此頁面是Template:If in page的模板文件。 此頁面可能包含了模板的使用說明、分類和其他內容。 |
| File:Lua-Logo.svg | 此模板使用Lua語言: |
| 警告 | 此模板文件被參照於約728,000個頁面,佔全部頁面的15%。 為了避免造成大規模的影響,所有對此模板文件的編輯應先於沙盒、測試樣例或您的沙盒上測試。 測試後無誤的版本可以一次性地加入此模板文件中,但是修改前請務必於討論頁發起討論。 模板參照數量會自動更新。 |
注意事項[編輯]
簡介[編輯]
此模板可用來偵測和匹配頁面中是否有指定的mw.ustring模型,並輸出為自訂結果。
參數及使用方法[編輯]
{{If in page|模型|存在時的輸出值|不存在時的返回值|page=|subst=}}{{#invoke:If in page|main|模型|存在時的輸出值|不存在時地返回值|page=|subst=}}
範例[編輯]
- 偵測和匹配當前頁面中是否存在模型,並輸出自訂結果:
{{If in page|模型|存在時輸出的結果|不存在時輸出的結果}}- 偵測和匹配指定頁面中是否存在模型,並輸出自訂結果:
{{If in page|模型|存在時輸出的結果|不存在時輸出的結果|page=頁面}}
參數資料[編輯]
<templatedata> { "format": "inline", "params": { "1": { "label": "模型", "description": "一個能被mw.ustring.match有效偵測和匹配的模型。", "type": "content", "required": true }, "2": { "label": "存在值", "description": "可在頁面中偵測到模型的輸出值。", "type": "content", "suggested": true }, "3": { "label": "不在值", "description": "無法在頁面中偵測到模型的輸出值。", "type": "content", "suggested": true }, "page": { "label": "頁面", "description": "在指定頁面上偵測模型,而非在當前的頁面。", "type": "wiki-page-name", "suggested": true }, "subst": { "label": "替換", "description": "If set, then value if present will have %n replaced with capture groups, see doc", "type": "boolean" } } } </templatedata>