Template:does-template-exist/documentation

Hello, you have come here looking for the meaning of the word Template:does-template-exist/documentation. In DICTIOUS you will not only get to know all the dictionary meanings for the word Template:does-template-exist/documentation, but we will also tell you about its etymology, its characteristics and you will know how to say Template:does-template-exist/documentation in singular and plural. Everything you need to know about the word Template:does-template-exist/documentation you have here. The definition of the word Template:does-template-exist/documentation will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofTemplate:does-template-exist/documentation, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.
Documentation for Template:does-template-exist. [edit]
This page contains usage information, categories, interwiki links and other content describing the template.
Warning: dangerous template
This template hacks around an important safety feature of MediaWiki. It must not be used unless it's both safe and necessary to bypass this feature. In particular, the following requirements must be met:+
  • The tested-for template must be one that is supposed to exist 100% of the time, and that does exist >99% of the time.
    • That is, this template is not a way to look for a template that may or may not exist, but a way to confirm that a template exists before calling it.
    • Otherwise, we're violating the spirit of the restriction on {{#ifexist:}}.
    • Ideally, if this template finds that the template doesn't exist, then the calling template should add the page to a cleanup category or something.
  • The tested-for template must contain only a small amount of wikitext.
    • This is because of the way this template is implemented: it actually transcludes the tested-for template and does some string-comparisons. This is unfortunate, but irremediable.
  • The calling template must be the type of template that occurs many times in a single entry.

This template is a total hack around the fact that MediaWiki considers #ifexist: to be an expensive parser function, and therefore limits the number of times it can be used on a page. This is somewhat reasonable — detecting whether a page exists is, in fact, much more expensive than evaluating a simple parser-function like #if: and #switch: — but on the other hand, this is something that MediaWiki does all the time, whenever a page contains a link or includes a template or belongs to a category (since MediaWiki has to distinguish redlinks from bluelinks, and also hidden categories from regular ones — let alone all the overhead of actually including a template). So, while #ifexist: should not be overused, there are a few use-cases where it really does make sense to test if a page exists, and where MediaWiki's restriction really is not reasonable. If your use-case meets the requirements in the box above, then this template is for you.

Usage

This:

{{#if:{{does-template-exist|foobar}}|yes|no}}

produces yes if {{foobar}} exists, and no if it does not.

It may also be substituted:

{{subst:#if:{{subst:does-template-exist|foobar}}|yes|no}}

See also