Merge "Only set indexOffset when the function name is indexed"

This commit is contained in:
jenkins-bot 2014-09-08 16:49:03 +00:00 committed by Gerrit Code Review
commit 7808ee7f65
2 changed files with 19 additions and 1 deletions

View file

@ -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 ) );

View file

@ -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