Jump to content

Template:Template usage: Difference between revisions

From Fifth Empire Wiki
doc shows now
comments, whitespace, "quotes" added
Line 1: Line 1:
<noinclude>{{Documentation}}</noinclude><onlyinclude>{{#switch:{{{prefix|{{FULLPAGENAME}}}}}
<noinclude>{{Documentation}}</noinclude>
|{{FULLPAGENAME}} = {{#if:{{{pattern|}}}|Phase one of two: '''a test regexp''' "<kbd>{{{pattern}}}</kbd>".}}
 
|#default = {{#if:{{{pattern|}}}|Phase two: '''a tested regexp''' "<kbd>{{{pattern}}}</kbd>".}}
<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, for expected pattern, else no insource: search
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 starting a /regexp
-->{{#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 /i search  
   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"+.
   -->[^}]+<!-- One or more characters before the closing curly bracket
   -->[^}]*<!-- Zero or more (*) of the [character class], "NO^ curly brackets".
   -->{{{pattern}}}/<!--/regexp/ of the pattern, ending of the regexp/
   -->{{{pattern}}}/"<!--User part: the sub-pattern regexp, match within template.
   Now add a space and a search domain.
  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

Phase one of two: a test regexp "{{{pattern}}}". Perform a search for template Val on just this page.