Module talk:Template invocation: Difference between revisions

Content deleted Content added
Line 18:
The issue seems to be caused by template invocation, in which a positional parameter is <code><nowiki>{{=}}</nowiki></code> and at least one named parameter is present. I've added <code>test14_equals_sign_parameter</code> to [[Module:Template test case/testcases]] to demonstrate the issue. —⁠[[User:Andrybak|andrybak]] ([[User talk:Andrybak|talk]]) 14:25, 19 May 2020 (UTC)
:I haven't looked at what this module does or how it's used but the cause of the error is simple. A loop at line 104 uses pairs(invArgs) to put each key (parameter name) into the invArgs_list array. That will include numbers like 1 if the first unnamed parameter is entered, and strings like the names of any named parameters. Line 107 then fails because it cannot sort a mixture of numbers and strings. Someone would have to work out what the module wants to do at that point (why is it sorting the parameters names?) and decide what should happen to numbered parameters. Perhaps they should be omitted, or converted to strings. Or, add a custom sort routine to put the numbers before the strings. Ping me if help is wanted with implementing any of this after deciding what is wanted. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 23:39, 19 May 2020 (UTC)
::{{u|Johnuniq}}, at line 95, the module tries to guess if <code>1=foo=bar</code> was passed to the template:
::<syntaxhighlight lang="Lua" line="yes" start="95">
:: if type(v) == 'string' and v:find('=', 1, true) then
:: -- Likely something like 1=foo=bar, we need to do it as a named arg
:: break
:: end
::</syntaxhighlight>
::My guess is that this heuristic fails when characters on the left of equals sign are not a valid parameter name or index. Namely, two opening curly braces, as is the case with transclusion of {{tl|{{=}}}} as a template. —⁠[[User:Andrybak|andrybak]] ([[User talk:Andrybak|talk]]) 00:13, 20 May 2020 (UTC)