සැකිල්ල:does-template-exist
- පහත දැක්වෙන උපදෙස්, සැකිල්ල:does-template-exist/documentation හි පිහිටා ඇත. සැකිල්ල:does-template-exist/documentation]]. [සංස්කරණය]
- ප්රයෝජනවත් සබැඳි: උප පිටු ලැයිස්තුව • සබැඳි • යළි යොමු • transclusions • errors (parser/module) • sandbox
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
[සංස්කරණය]{{#ifexist:}}