ទំព័រគំរូ:str len/doc
This is the {{str len}}
meta-template.
It takes a string as parameter and returns its length (after stripping any leading and/or trailing whitespace). It can count up to 500 in length, and returns 500 for strings that are too long.
It must be subst:'d, so is only useful in new-entry-creation templates, subst:'d templates, and so on.
Examples
កែប្រែIf the parameter is empty or undefined it is considered to be of zero length:
{{subst:str len}}
becomes 0{{subst:str len|}}
becomes 0{{subst:str len| }}
becomes 0
It counts the length correctly, even if the string contains spaces, looks like a number, or contains special characters:
{{subst:str len| ab cde }}
becomes 6
{{subst:str len| 1234567 }}
becomes 7
{{subst:str len| café åäö }}
becomes 8
It can measure strings up to 500 in length, and returns 500 for strings that are too long:
{{subst:str len| 499-characters... }}
becomes 499{{subst:str len| 1000-characters... }}
becomes 500
Technical details
កែប្រែMediaWiki has no parser function or magic word to measure string lengths, and measuring string length using template code is very heavy on the servers; thus this template, even though optimized about as much as it can be, must, by community decision, be subst:'d.
This template substitutes {{str len/core}}
, which does most of the work. For documentation on the internal workings of these two templates see /core.
See also
កែប្រែ- caps (returns a particular letter, either in upper or lower cases)
- str len (returns the number of characters of a string)
- theordinal (returns "first" from 1, "second" from 2, etc.)
- theplural (returns "suffixes" from suffix, "verbs" from verb, etc.)
- navbox (generates a collapsible box)
- ! (returns a vertical pipe: |)
- !! (returns two vertical pipes: ||)
- (! (returns a left brace followed by a vertical pipe: {|)
- !) (returns a vertical pipe followed by a right brace: |})
- !- (returns a vertical pipe followed by a dash: |-)
Languages, families and scripts:
- Module:language utilities
- langname (returns a language name from the same language name)
- langrev (returns the language code of a given language name)
- languageshift (differentiates between "American Sign Language" and "American Sign Language language", among other related languages)
- family (returns the family from a subfamily)
- script (returns a script name from a script code)
- scriptrev (returns a script code from a script name)
Pages:
- catlangcode (returns the name of a topical category, notably by never displaying the code en:)
- catlangname (returns the name of a lexical or other category similarly named)
- deftempboiler (generates a definition template)
- edit (generates an "edit" button)