Jump to content

Template:Template usage: Difference between revisions

From Fifth Empire Wiki
minor fix
m 53 revisions imported from wikipedia:Template:Template_usage
 
(41 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<onlyinclude>{{#switch: {{{prefix|{{FULLPAGENAME}}}}}
<!-- Curly brackets matching should ignore [^}], \{{!}}; insource:/\{} is OK.
--><onlyinclude><!--
Make a search link.
-->{{plain link
  |url =
    {{fullurl:Special:Search|search=<!--
        -->{{urlencode:<!-- encodes spaces, so let's avoid unnecessary spaces.


|{{FULLPAGENAME}} = Phase one of two: '''a test regexp''' /<kbd>{{{pattern}}}</kbd>/.
          Build this query:
          hastemplate: template insource:/\{\{ *[Tt]emplate *\| *[^}]*pattern/


|#default = Readied '''a tested regexp''' /<kbd>{{{pattern}}}</kbd>/.}}<!--
          Add the ever present "hastemplate:" filter and a space
          -->hastemplate:"{{{template|{{{1|Template usage}}}}}}" <!--  


--><span class="plainlinks">[{{fullurl:Special:Search|search={{urlencode: 
          Add the "insource:/\{\{ *"
hastemplate:{{{template|Val}}} <!-- hastemplate, an all-important filter.
          -->insource:/\{\{ *<!--
A filter is always recommended for, what is expected, an insource:/regexp pattern/.
-->{{#if:{{{pattern|}}}<!-- Do insource. If no pattern, hastemplate is done.
  -->| insource:/\{<!-- 1st a space. Start /{regexp/ with curly bracket.
  -->[{{#invoke:String|sub<!--
  Now save from an expensive, /regexp/i, case-insensitive search
  by outputing [Xx] where x is first letter of template 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: \|, 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}}}/<!--User part: the sub-pattern regexp, match within template.
  And you see the ending / of the regexp/. 
-->}}<!-- end #if:pattern. No else part. Nothing to do if no pattern is given.
  There's always the hastemplate part, even if no insource:/regexp/ part.


  There's also always another filter, usually prefix, but defaults to intitle.
          Add the "[Tt]".
  Always add a filter to the search domain to make the search less expensive.
          Save from an expensive, /regexp/i.
  Never let all namespaces be searched at once because user defaults to that.
          -->[{{#invoke:String|sub<!-- saw first [ of a "[Tt]"  -->
  Purpose of this template: make inefficient searches fast via tests/limits.
          |{{uc:{{{template|{{{1|Template usage}}}}}}}}|1|1}}{{#invoke:String|sub
  Start with a space.
          |{{lc:{{{template|{{{1|Template usage}}}}}}}}|1|1}}]{{#invoke:String|sub
--> {{#if:{{{prefix|}}}
          <!--                                               ^
  | {{#switch:{{{prefix}}}
                                                    You saw ].
      |#default = prefix:{{{prefix}}}
      |n = prefix:{{NAMESPACE}}:
      |0|: = prefix:{{ns:0}}:
      |1 = prefix:{{ns:1}}:
      |2 = prefix:{{ns:2}}:
      |3 = prefix:{{ns:3}}:
      |4 = prefix:{{ns:4}}:
      |5 = prefix:{{ns:5}}:
      |6 = prefix:{{ns:6}}:
      |7 = prefix:{{ns:7}}:
      |8 = prefix:{{ns:8}}:
      |9 = prefix:{{ns:9}}:
      |10 = prefix:{{ns:10}}:
      |11 = prefix:{{ns:11}}:
      |12 = prefix:{{ns:12}}:
      |13 = prefix:{{ns:13}}:
      |14 = prefix:{{ns:14}}:
      |15 = prefix:{{ns:15}}:
      |100 = prefix:{{ns:100}}:
      |101 = prefix:{{ns:101}}:
      |108 = prefix:{{ns:108}}:
      |109 = prefix:{{ns:109}}:
      |118 = prefix:{{ns:118}}:
      |119 = prefix:{{ns:119}}:
    }}<!-- else if prefix not given, filter down to current page name
-->| prefix:{{FULLPAGENAME}}
    }}<!-- end #if -->
  }} <!-- end urlencode -->
}}<!-- end fullurl  --> </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 "emplate", the rest of the template name, starting from char 2.-->
          |{{{template|{{{1|Template usage}}}}}}|2}}<!--


It starts the search domain in the current page "fullpagename",
          Add the tricky regexp part.
that is a specific page or personal sandbox. Hone the regexp
          --> *\{{!}}[^}]*<!-- optional space " *" around initial pipe
before releasing it into the wild.  
          initial pipe is \|, i.e. \{{!}}
Use ":" for main, "n" for current namespace.
          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


--> {{#switch:{{{prefix|{{FULLPAGENAME}}}}}
          Add the users regexp pattern part and closing /.
|{{FULLPAGENAME}} = on just this page.
          -->{{{pattern|{{{2|''regexp''}}}}}}/<!--
|:|0 = in the main namespace.
 
|n = in the {{NAMESPACE}} namespace.
          Add "prefix:" You see the space before it.
|1 = in the {{ns:1}} namespace.
          --> prefix:<!--
|2 = in the {{ns:2}} namespace.
          -->{{#switch:<!-- add namespace "numbers and letters" recognition -->
|3 = in the {{ns:3}} namespace.
            {{{prefix|{{{3|}}}}}}
|4 = in the {{ns:4}} namespace.
            |#default = {{{prefix|{{{3|{{FULLPAGENAME}}}}}}}}
|5 = in the {{ns:5}} namespace.
            |n = {{NAMESPACE}}
|6 = in the {{ns:6}} namespace.
            |0|: = :
|7 = in the {{ns:7}} namespace.
            |1 = {{ns:1}}:
|8 = in the {{ns:8}} namespace.
            |2 = {{ns:2}}:
|9 = in the {{ns:9}} namespace.
            |3 = {{ns:3}}:
|10 = in the {{ns:10}} namespace.
            |4 = {{ns:4}}:
|11 = in the {{ns:11}} namespace.
            |5 = {{ns:5}}:
|12 = in the {{ns:12}} namespace.
            |6 = {{ns:6}}:
|13 = in the {{ns:13}} namespace.
            |7 = {{ns:7}}:
|14 = in the {{ns:14}} namespace.
            |8 = {{ns:8}}:
|15 = in the {{ns:15}} namespace.
            |9 = {{ns:9}}:
|100 = in the {{ns:100}} namespace.
            |10 = {{ns:10}}:
|101 = in the {{ns:101}} namespace.
            |11 = {{ns:11}}:
|108 = in the {{ns:108}} namespace.
            |12 = {{ns:12}}:
|109 = in the {{ns:109}} namespace.
            |13 = {{ns:13}}:
|118 = in the {{ns:118}} namespace.
            |14 = {{ns:14}}:
|119 = in the {{ns:119}} namespace.
            |15 = {{ns:15}}:
|#default = in all titles starting with the characters "{{{prefix}}}".
            |100 = {{ns:100}}:
}}</onlyinclude>
            |101 = {{ns:101}}:
<noinclude>{{Documentation}}</noinclude>
            |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