GuildWiki has been locked down: anonymous editing and account creation are disabled. Current registered users are unaffected. Leave any comments on the Community Portal.

Template:Count*

From GuildWiki
Jump to: navigation, search

0

Usage[edit source]

  • {{Count*|some*string*or*text}}
counts the number of occurrences of the asterisk (*) in the text.
The example returns 3 (should be 3).
 {{Count*|1=some*string*or*text*with = in*it}}
{{Count*|
* this
* template
* counts
* lists
}}

gives 4 (4)

{{Count*|1={{Count*/demo }} }}

gives Expression error: Unexpected < operator. because it counts the * from the signature list entries in Count*/demo(as long nobody uses * in their sig)

Recursion[edit source]

This template repeatedly calls itself. Usually Mediawiki detects this and breaks the recursion. The workaround is to use a redirect. Therefore, Template:Count** up to (currently) Template:Count******* redirect to Count*; the number of asterisks indicates the recursion level. Count* can count at most 5*2n-1 asterisks, where n indicates the recursion depth (= number of asterisks). If the asterisks are not evenly distributed throughout the text, the number is somewhat less.

Server Resources[edit source]

 Pre-expand include size: 378101/2097152 bytes
 Post-expand include size: 63374/2097152 bytes
 Template argument size: 257545/2097152 bytes
 #ifexist count: 0/100

Unfortunately this means that using several of these counts on a single page is probably not feasible.

The template can be easily adapted to take the key being counted (currently fixed key=*).