mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
synced 2024-11-28 02:00:01 +00:00
Merge "Only set indexOffset when the function name is indexed"
This commit is contained in:
commit
7808ee7f65
|
@ -102,9 +102,14 @@ class ScribuntoHooks {
|
||||||
}
|
}
|
||||||
$functionName = trim( $frame->expand( $args[1] ) );
|
$functionName = trim( $frame->expand( $args[1] ) );
|
||||||
|
|
||||||
|
$bits = $args[1]->splitArg();
|
||||||
unset( $args[0] );
|
unset( $args[0] );
|
||||||
unset( $args[1] );
|
unset( $args[1] );
|
||||||
$childFrame = $frame->newChild( $args, $title, 1 );
|
|
||||||
|
// If $bits['index'] is empty, then the function name was parsed as a
|
||||||
|
// key=value pair (because of an equals sign in it), and since it didn't
|
||||||
|
// have an index, we don't need the index offset.
|
||||||
|
$childFrame = $frame->newChild( $args, $title, $bits['index'] === '' ? 0 : 1 );
|
||||||
$result = $module->invoke( $functionName, $childFrame );
|
$result = $module->invoke( $functionName, $childFrame );
|
||||||
$result = UtfNormal::cleanUp( strval( $result ) );
|
$result = UtfNormal::cleanUp( strval( $result ) );
|
||||||
|
|
||||||
|
|
|
@ -147,6 +147,10 @@ function p.getFrameTitle( frame )
|
||||||
return frame:getTitle()
|
return frame:getTitle()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
p['test=InFunctionName'] = function( frame )
|
||||||
|
return frame.args[1]
|
||||||
|
end
|
||||||
|
|
||||||
return p
|
return p
|
||||||
!! endarticle
|
!! endarticle
|
||||||
|
|
||||||
|
@ -461,3 +465,12 @@ You called the one method from mt1
|
||||||
You called the two method from mt2
|
You called the two method from mt2
|
||||||
</p>
|
</p>
|
||||||
!! end
|
!! end
|
||||||
|
|
||||||
|
!! test
|
||||||
|
Scribunto: Correct argument numbering with equals sign in function name
|
||||||
|
!! input
|
||||||
|
{{#invoke:test|test=InFunctionName|good|bad}}
|
||||||
|
!! result
|
||||||
|
<p>good
|
||||||
|
</p>
|
||||||
|
!! end
|
||||||
|
|
Loading…
Reference in a new issue