• Home
  • Random
  • Recent changes
  • Special pages
  • Settings
  • About MOASSpedia
  • Disclaimers
MOASSpedia
  • 216.73.216.55
  • Talk
  • Watchlist
  • Contributions
  • Log in

Template:If in page

Template Discussion
  • Language
  • Watch
  • History
  • Edit
    • Page information
    • Permanent link
    • What links here
Template documentation[view] [edit] [history] [purge]
This template uses Lua:
  • Module:If in page

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. in value 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.

Template parameters

ParameterDescriptionTypeStatus
Pattern1

A valid pattern for mw.ustring.match

Unknownrequired
Value if present2

The value to output if the pattern matches the content of the page

Contentsuggested
Value if absent3

The value to output if the pattern matches the content of the page

Contentsuggested
Pagepage

The page to search, if not the current page

Unknownoptional
subsub

If set, then value if present will have %n replaced with capture groups, see doc

Booleanoptional
The above documentation is transcluded from Template:If in page/doc. (edit | history)
Editors can experiment in this template's sandbox (create | mirror) and testcases (create) pages.
Add categories to the /doc subpage. Subpages of this template.
Retrieved from "https://moasspedia.org/w/index.php?title=Template:If_in_page&oldid=19153"
Categories:
  • Lua-based templates
  • Templates using TemplateData
Last edited on 14 July 2019, at 12:59

MOASSpedia

Content is available under Creative Commons Attribution-ShareAlike unless otherwise noted.
  • This page was last edited on 14 July 2019, at 12:59.
  • Content is available under Creative Commons Attribution-ShareAlike unless otherwise noted.
  • Privacy policy
  • About MOASSpedia
  • Disclaimers
  • Desktop