Template:Template usage: Difference between revisions
Appearance
doc shows now |
comments, whitespace, "quotes" added |
||
| Line 1: | Line 1: | ||
<noinclude>{{Documentation}}</noinclude><onlyinclude>{{#switch:{{{prefix|{{FULLPAGENAME}}}}} | <noinclude>{{Documentation}}</noinclude> | ||
|{{FULLPAGENAME}} = | |||
|#default = | <onlyinclude>{{#switch: {{{prefix|{{FULLPAGENAME}}}}} | ||
}}<!-- | |||
|{{FULLPAGENAME}} = Phase one of two: '''a test regexp''' "<kbd>{{{pattern}}}</kbd>". | |||
|#default = Readied '''a tested regexp''' "<kbd>{{{pattern}}}</kbd>".}}<!-- | |||
--><span class="plainlinks">[{{fullurl:Special:Search|search={{urlencode: | --><span class="plainlinks">[{{fullurl:Special:Search|search={{urlencode: | ||
hastemplate:{{{template|Val}}}<!-- Filter, | hastemplate:{{{template|Val}}}<!-- hastemplate acts as the all-important Filter. | ||
--> {{#if:{{{pattern|}}} | A filter is always recommended for, what is expected, an insource:/regexp pattern/. | ||
| insource:/\{<!-- a curly bracket | -->{{#if:{{{pattern|}}}<!--If no pattern, use only hastemplate. | ||
-->| insource:"/\{<!-- 1st a space. Start "/\{regexp/" with escaped curly bracket. | |||
-->[{{#invoke:String|sub<!-- | -->[{{#invoke:String|sub<!-- | ||
Now save from an expensive, case-insensitive | Now save from an expensive, /regexp/i, case-insensitive search | ||
by outputing [Xx] where x is first letter of name. --> | by outputing [Xx] where x is first letter of template name. --> | ||
|{{uc:{{{template|val}}}}}|1|1}}{{#invoke:String|sub | |{{uc:{{{template|val}}}}}|1|1}}{{#invoke:String|sub | ||
|{{lc:{{{template|val}}}}}|1|1}}]{{#invoke:String|sub | |{{lc:{{{template|val}}}}}|1|1}}]{{#invoke:String|sub | ||
|{{{template|val}}}|2}}\{{!}}<!-- Template name and its pipe. | |{{{template|val}}}|2}}\{{!}}<!-- Template name and its pipe: \|, i.e. \{{!}} | ||
Trickiest part: [character class "any char NOT^ a } ] "one or more of"+. | |||
-->[^}] | -->[^}]*<!-- Zero or more (*) of the [character class], "NO^ curly brackets". | ||
-->{{{pattern}}}/<!-- | -->{{{pattern}}}/"<!--User part: the sub-pattern regexp, match within template. | ||
Now add a | And you see the ending / of the regexp/. | ||
-->}} prefix:{{#switch:{{{prefix}}} | Its in "quotes" to allow for spaces in the pattern. | ||
Now add a filter to the search domain. These are expensive searches. | |||
Start with a space. | |||
-->}}<!-- end of #if: pattern, there's nothing to do if no pattern is given. | |||
There's only hastemplate part, but nothing to do for insource:"/regexp/" part. | |||
Always do the ''prefix:'' search parameter. | |||
Never let all namespaces be searched at once because user defaults to that. | |||
Purpose of this template: make inefficient searches fast via tests/limits. | |||
--> prefix:{{#switch:{{{prefix}}} | |||
|#default = {{FULLPAGENAME}} | |#default = {{FULLPAGENAME}} | ||
|n = {{NAMESPACE}}: | |n = {{NAMESPACE}}: | ||
Revision as of 00:14, 24 June 2015
File:Test Template Info-Icon - Version (2).svg Template documentation[create] [purge]
Phase one of two: a test regexp "{{{pattern}}}". Perform a search for template Val on just this page.