Module:String: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
(fix comment) |
(add description and whitespace handling option for len) |
||
Line 1: | Line 1: | ||
local str = {} |
local str = {} |
||
--[====[ |
|||
len |
|||
This function returns the length of the target string. |
|||
Usage: |
|||
{{#invoke:String|len|target_string|}} |
|||
OR |
|||
{{#invoke:String|pos|s=target_string}} |
|||
Parameters |
|||
s: The string whose length to report |
|||
If invoked using named parameters, Mediawiki will automatically remove any leading or |
|||
trailing whitespace from the target string. |
|||
]====] |
|||
function str.len( frame ) |
function str.len( frame ) |
||
local new_args = str._getParameters( frame.args, {'s'} ); |
|||
local s = new_args['s'] or ''; |
|||
return mw.ustring.len( s ) |
|||
end |
end |
||