Jump to content

Template:Template usage: Difference between revisions

From Fifth Empire Wiki
+ doc template
m 53 revisions imported from wikipedia:Template:Template_usage
 
(50 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<noinclude>{{Documentation}}</noinclude>{{#switch:{{{prefix|{{FULLPAGENAME}}}}}
<!-- Curly brackets matching should ignore [^}], \{{!}}; insource:/\{} is OK.
|{{FULLPAGENAME}} = {{#if:{{{pattern|}}}|Phase one of two: '''a test regexp''' "<kbd>{{{pattern}}}</kbd>".}}
--><onlyinclude><!--
|#default = {{#if:{{{pattern|}}}|Phase two: '''a tested regexp''' "<kbd>{{{pattern}}}</kbd>".}}
Make a search link.
}}<!--
-->{{plain link
  |url =  
    {{fullurl:Special:Search|search=<!--
        -->{{urlencode:<!-- encodes spaces, so let's avoid unnecessary spaces.


--><span class="plainlinks">[{{fullurl:Special:Search|search={{urlencode:
          Build this query:
hastemplate:{{{template|Val}}}<!-- Filter, for expected pattern, else no insource: search
          hastemplate: template insource:/\{\{ *[Tt]emplate *\| *[^}]*pattern/
-->{{#if:{{{pattern|}}}
  | insource:/\{<!-- a curly bracket starting a /regexp
  -->[{{#invoke:String|sub<!--
  Now save from an expensive, case-insensitive /i search
  by outputing [Xx] where x is first letter of name. -->
  |{{uc:{{{template|val}}}}}|1|1}}{{#invoke:String|sub
  |{{lc:{{{template|val}}}}}|1|1}}]{{#invoke:String|sub
  |{{{template|val}}}|2}}\{{!}}<!-- Template name and its pipe.


  -->[^}]+<!-- One or more characters before the closing curly bracket
          Add the ever present "hastemplate:" filter and a space
  -->{{{pattern}}}/<!--/regexp/ of the pattern, ending of the regexp/
          -->hastemplate:"{{{template|{{{1|Template usage}}}}}}" <!--  
  Now add a space and a search domain.
-->}} prefix:{{#switch:{{{prefix}}}
|#default = {{FULLPAGENAME}}
|n = {{NAMESPACE}}:
|0|: = {{ns:0}}:
|1 = {{ns:1}}:
|2 = {{ns:2}}:
|3 = {{ns:3}}:
|4 = {{ns:4}}:
|5 = {{ns:5}}:
|6 = {{ns:6}}:
|7 = {{ns:7}}:
|8 = {{ns:8}}:
|9 = {{ns:9}}:
|10 = {{ns:10}}:
|11 = {{ns:11}}:
|12 = {{ns:12}}:
|13 = {{ns:13}}:
|14 = {{ns:14}}:
|15 = {{ns:15}}:
|100 = {{ns:100}}:
|101 = {{ns:101}}:
|108 = {{ns:108}}:
|109 = {{ns:109}}:
|118 = {{ns:118}}:
|119 = {{ns:119}}:
}}}}}}</span> Perform a search {{#if:{{{pattern|}}}
| within all instances of | for }} template {{ucfirst: {{{template|val}}}}} ] <!--


DONE.  Now inform the user what the search link does.
          Add the "insource:/\{\{ *"
          -->insource:/\{\{ *<!--


It starts the search domain in the current page "fullpagename",  
          Add the "[Tt]".
that is a specific page or personal sandbox. Hone the regexp
          Save from an expensive, /regexp/i.
before releasing it into the wild. 
          -->[{{#invoke:String|sub<!-- saw first [ of a "[Tt]" -->
Use ":" for main, "n" for current namespace.
          |{{uc:{{{template|{{{1|Template usage}}}}}}}}|1|1}}{{#invoke:String|sub
          |{{lc:{{{template|{{{1|Template usage}}}}}}}}|1|1}}]{{#invoke:String|sub
          <!--                                              ^
                                                    You saw ].  


--> {{#switch:{{{prefix|{{FULLPAGENAME}}}}}
          Add "emplate", the rest of the template name, starting from char 2.-->
|{{FULLPAGENAME}} = on just this page.
          |{{{template|{{{1|Template usage}}}}}}|2}}<!--
|:|0 = in the {{ns:0}} namespace.
|n = in namespace "{{NAMESPACE}}".
|1 = in the {{ns:1}} namespace
|2 = in the {{ns:2}} namespace
|3 = in the {{ns:3}} namespace
|4 = in the {{ns:4}} namespace
|5 = in the {{ns:5}} namespace
|6 = in the {{ns:6}} namespace
|7 = in the {{ns:7}} namespace
|8 = in the {{ns:8}} namespace
|9 = in the {{ns:9}} namespace
|10 = in the {{ns:10}} namespace
|11 = in the {{ns:11}} namespace
|12 = in the {{ns:12}} namespace
|13 = in the {{ns:13}} namespace
|14 = in the {{ns:14}} namespace
|15 = in the {{ns:15}} namespace
|100 = in the {{ns:100}} namespace
|101 = in the {{ns:101}} namespace
|108 = in the {{ns:108}} namespace
|109 = in the {{ns:109}} namespace
|118 = in the {{ns:118}} namespace
|119 = in the {{ns:119}} namespace
|#default = in all titles starting with the characters "{{{prefix}}}".


Or choose a [[H:S| prefix filter]] from: {{namespaces}}
          Add the tricky regexp part.
}}
          --> *\{{!}}[^}]*<!-- optional space " *" around initial pipe
          initial pipe is \|, i.e. \{{!}}
          Trickiest part: [character class] inverted with ^:  [^any char NOT }]
          Zero or more (*) of those "non-curly brackets".
          All this stuff always matches, shows in bold in the search results
 
          Add the users regexp pattern part and closing /.
          -->{{{pattern|{{{2|''regexp''}}}}}}/<!--
 
          Add "prefix:" You see the space before it.
          --> prefix:<!--
          -->{{#switch:<!-- add namespace "numbers and letters" recognition -->
            {{{prefix|{{{3|}}}}}}
            |#default = {{{prefix|{{{3|{{FULLPAGENAME}}}}}}}}
            |n = {{NAMESPACE}}
            |0|: = :
            |1 = {{ns:1}}:
            |2 = {{ns:2}}:
            |3 = {{ns:3}}:
            |4 = {{ns:4}}:
            |5 = {{ns:5}}:
            |6 = {{ns:6}}:
            |7 = {{ns:7}}:
            |8 = {{ns:8}}:
            |9 = {{ns:9}}:
            |10 = {{ns:10}}:
            |11 = {{ns:11}}:
            |12 = {{ns:12}}:
            |13 = {{ns:13}}:
            |14 = {{ns:14}}:
            |15 = {{ns:15}}:
            |100 = {{ns:100}}:
            |101 = {{ns:101}}:
            |118 = {{ns:118}}:
            |119 = {{ns:119}}:
            |710 = {{ns:710}}:
            |711 = {{ns:711}}:
            |828 = {{ns:828}}:
            |829 = {{ns:829}}:
          }}
        }}<!-- End urlencode. -->
      }}<!-- End fullurl
    url done
    Now for name param of plainlinks.
 
  Appearance of link looks just like the query, unless labeled.
  So we're rebuilding the query just for show this time. -->
  |name = <!-- for commentary see duplicate above -->
    {{#if:
      {{{label|{{{4|}}}}}}
      |{{{label|{{{4}}}}}}
      |{{#if:
        {{{prefix|{{{3|}}}}}}
 
        |hastemplate:"{{{template|{{{1|Template usage}}}}}}" <!--
        -->insource:/\{\{ *<!--
        -->&#91;{{#invoke:String|sub<!-- saw first [ of a "[Tt]"  -->
          |{{uc:{{{template|{{{1|Template usage}}}}}}}}|1|1}}{{#invoke:String|sub
          |{{lc:{{{template|{{{1|Template usage}}}}}}}}|1|1}}&#93;{{#invoke:String|sub
          |{{{template|{{{1|Template usage}}}}}}|2}}<!--    ^
        --> *\{{!}}&#91;^}&#93;*<!-- optional space " *" around initial pipe
        -->{{#invoke:String|replace
          |{{#invoke:String|replace
            |{{{pattern|{{{2|''regexp''}}}}}}<!-- Given pattern
          -->|[|&#91;}}<!-- Replace any/all [ with HTML symbol
        -->|]|&#93;}}/<!-- replace any/all ] with there HTML symbol
        --> prefix:<!--
        -->{{#switch:<!-- add namespace "numbers and letters" recognition -->
          {{{prefix|{{{3|}}}}}}
          |#default = {{{prefix|{{{3|{{FULLPAGENAME}}}}}}}}
          |n = {{NAMESPACE}}
          |0|: = <nowiki />:
          |1 = {{ns:1}}:
          |2 = {{ns:2}}:
          |3 = {{ns:3}}:
          |4 = {{ns:4}}:
          |5 = {{ns:5}}:
          |6 = {{ns:6}}:
          |7 = {{ns:7}}:
          |8 = {{ns:8}}:
          |9 = {{ns:9}}:
          |10 = {{ns:10}}:
          |11 = {{ns:11}}:
          |12 = {{ns:12}}:
          |13 = {{ns:13}}:
          |14 = {{ns:14}}:
          |15 = {{ns:15}}:
          |100 = {{ns:100}}:
          |101 = {{ns:101}}:
          |118 = {{ns:118}}:
          |119 = {{ns:119}}:
          |710 = {{ns:710}}:
          |711 = {{ns:711}}:
          |828 = {{ns:828}}:
          |829 = {{ns:829}}:
        }}
      |{{#invoke:String|replace
          |{{#invoke:String|replace
            |'''Testing''' <kbd>{{{pattern|{{{2}}}}}}</kbd> '''on this page'''<!--
          -->|[|&#91;}}<!-- Replace any/all [ with HTML symbol
        -->|]|&#93;}}<!-- replace any/all ] with there HTML symbol-->
      }}
  }}
}}<!-- End of plainlinks
--></onlyinclude><noinclude>{{Documentation}}</noinclude>

Latest revision as of 20:49, 24 January 2026

Testing {{{2}}} on this page