Template:Str len/doc
Jump to navigation
Jump to search
{{#invoke:Message box|mbox}} {{#invoke:Message box|ombox}} {{#invoke:Lua banner|main}}
This is the {{str len}} meta-template.
It takes a string as parameter and returns its length (excluding spaces at the start and end). It can now count as high as necessary.
Examples
If the parameter is empty or undefined it is considered to be of zero length:
{{str len}}
returns {{safesubst:#invoke:String|len|s=}}{{str len|}}
returns {{safesubst:#invoke:String|len|s=}}{{str len| }}
returns {{safesubst:#invoke:String|len|s= }}
It counts the length correctly, even if the string contains spaces, looks like a number, or contains special characters:
{{str len| ab cde }}
returns {{safesubst:#invoke:String|len|s= ab cde }}
{{str len| 1234567 }}
returns {{safesubst:#invoke:String|len|s= 1234567 }}
{{str len| café åäö }}
returns {{safesubst:#invoke:String|len|s= café åäö }}
{{str len| 499-characters... }}
returns {{safesubst:#invoke:String|len|s= abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi }}{{str len| 1000-characters... }}
returns {{safesubst:#invoke:String|len|s= abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghij }}
Template data
This is the TemplateData documentation for this template used by VisualEditor and other tools.
Str len
<templatedata> {
"description": "The template takes a string as parameter and returns its length, excluding spaces at the start and end of the string", "params": { "1": { "label": "Alpha-numeric text", "description": "The string to be counted", "type": "string", "required": true } }
} </templatedata>
Technical details
This is the first general-purpose template to be implemented using mw:Extension:Scribunto. The Lua code is located in Module:String.
See also
{{#invoke:Navbox|navbox}}