Content deleted Content added
→Protected edit request on 18 October 2024: new section |
|||
Line 166:
[[User:Od1n|Od1n]] ([[User talk:Od1n|talk]]) 03:26, 3 September 2024 (UTC)
:[{{fullurl:Module:String|diff=prev&oldid=1243840019}} 1243840019], thanks. [[User:Od1n|Od1n]] ([[User talk:Od1n|talk]]) 22:38, 3 September 2024 (UTC)
== Protected edit request on 18 October 2024 ==
{{edit fully-protected|Module:String|answered=no}}
The value returned by a module function must always be a string, however some functions here return numbers (these are <code>[[Module:String#len|len]]</code>, <code>[[Module:String#str_find|str_find]]</code>, <code>[[Module:String#find|find]]</code> and <code>[[Module:String#count|count]]</code>). Could you please apply [[Special:Diff/1251805774/1251806211|this diff]]? You can just copy and paste the code at [[Special:PermanentLink/1251806211|this permanent link]].
Although unnoticeable when used in normal wikitext, this can create problems when [[Module:String]] is invoked by other modules.
For instance, focusing on the <code>[[Module:String#len|len]]</code> function, for each argument passed, a template named <code>mytemplate</code> containing the following code
<syntaxhighlight lang="wikitext">{{#invoke:params|mapping_by_invoking|string|len|mapping_by_replacing|^.*$|%0 mod 3|1|for_each|[$#:$@]}}</syntaxhighlight>
should print <syntaxhighlight lang="wikitext" inline>[PARAMETER-NAME:LENGTH-OF-PARAMETER mod 3]</syntaxhighlight>
The code above invokes <code>{{mfl|string|len|...}}</code> for each parameter passed. Then it attempts to replace the lengths saved with <code>%0 mod 3</code>, i.e. by adding <code> mod 3</code> at the end of each parameter. And so, for instance, <syntaxhighlight lang="wikitext" inline>{{mytemplate|hello|world|foo|bar}}</syntaxhighlight> should print
: [1:5 mod 3][2:5 mod 3][3:3 mod 3][4:3 mod 3]
However, since <code>{{mfl|string|len|...}}</code> returns a number, any attempt to do string manipulation with the number returned will generate an error. -- [[User:Grufo|Grufo]] ([[User talk:Grufo|talk]]) 05:17, 18 October 2024 (UTC)
|