Jump to content

Template:Template usage: Difference between revisions

From Fifth Empire Wiki
quotes don't work as stated?
m 53 revisions imported from wikipedia:Template:Template_usage
 
(46 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<noinclude>{{Documentation}}</noinclude>
<!-- 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.


<onlyinclude>{{#switch: {{{prefix|{{FULLPAGENAME}}}}}
          Build this query:
          hastemplate: template insource:/\{\{ *[Tt]emplate *\| *[^}]*pattern/


|{{FULLPAGENAME}} = Phase one of two: '''a test regexp''' "<kbd>{{{pattern}}}</kbd>".
          Add the ever present "hastemplate:" filter and a space
          -->hastemplate:"{{{template|{{{1|Template usage}}}}}}" <!--


|#default = Readied '''a tested regexp''' "<kbd>{{{pattern}}}</kbd>".}}<!--
          Add the "insource:/\{\{ *"
          -->insource:/\{\{ *<!--


--><span class="plainlinks">[{{fullurl:Special:Search|search={{urlencode: 
          Add the "[Tt]".
hastemplate:{{{template|Val}}} <!-- hastemplate, an all-important filter.
          Save from an expensive, /regexp/i.
A filter is always recommended for, what is expected, an insource:/regexp pattern/.
          -->[{{#invoke:String|sub<!-- saw first [ of a "[Tt]-->
-->{{#if:{{{pattern|}}}<!-- Do insource. If no pattern, hastemplate is done.
          |{{uc:{{{template|{{{1|Template usage}}}}}}}}|1|1}}{{#invoke:String|sub
  -->| insource:/\{<!-- 1st a space. Start /\{regexp/ with escaped curly bracket.
          |{{lc:{{{template|{{{1|Template usage}}}}}}}}|1|1}}]{{#invoke:String|sub
  -->[{{#invoke:String|sub<!--
          <!--                                               ^
  Now save from an expensive, /regexp/i, case-insensitive search
                                                    You saw ].
  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/. 
  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}}
|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 "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 {{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 "prefix:" You see the space before it.
}}</onlyinclude>
          --> 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