Template:If in page/doc
Jump to navigation
Jump to search
This is a documentation subpage for Template:If in page. It contains usage information, categories and other content that is not part of the original template page. |
This template uses Lua: |
This template searches the current page for a provided Lua mw.ustring pattern. If you need help with these, you could ask Wikipedia talk:Lua, Wikipedia:Village pump (technical), or a user who knows Lua.
Note: the pattern is parsed by MediaWiki before being sent to the module, this means templates and magic words are decoded. If you want to add a |
pipe character use {{!}}
.
Usage
{{If in page |pattern |value if present |value if absent}}
searches the current page for a given pattern{{If in page |pattern |value if present |value if absent |page=page}}
can be used to search a page other than the current page{{If in page |pattern |value if present |value if absent |sub=yes}}
if the pattern matches, substitutes%1
,%2
,%3
, etc. invalue if present
with first, second, third, etc. capture groups. Does not work with%0
.
Examples
{{If in page |%{%{[Uu]se British English%}%}|colour|color}}
would output colour if a page contains {{Use British English}} or color if it does not
TemplateData
This is the TemplateData for this template used by TemplateWizard, VisualEditor and other tools. Click here to see a monthly parameter usage report for this template based on this TemplateData.
TemplateData for If in page
No description.
Parameter | Description | Type | Status | |
---|---|---|---|---|
Pattern | 1 | A valid pattern for mw.ustring.match | Unknown | required |
Value if present | 2 | The value to output if the pattern matches the content of the page | Content | suggested |
Value if absent | 3 | The value to output if the pattern matches the content of the page | Content | suggested |
Page | page | The page to search, if not the current page | Unknown | optional |
sub | sub | If set, then value if present will have %n replaced with capture groups, see doc | Boolean | optional |