Pergunta

I have a template with a parameter url (this works fine, I am able to output its value).

I have a plugin that takes also a parameter path (this works fine when I hard code the value).

I'd like to pass the {{{url}}} value from the template to my plugin but I can't achieve that.

Here is the code of my template:

'''Source code: ''' <MyPlugin path="{{{url}}}" .../>

In my plugin I dump the content of the $args parameters:

function MyPluginRender( $input, $args, $parser )
{
    var_dump($args);
}

And it outputs:

array(2) {
  ["path"]=>
  string(9) "{{{url}}}"
  ...
}

In fact it seems the substitution is disabled in some places. I tried several stuffs from this page http://en.wikipedia.org/wiki/Help:Template#Handling_parameters but w/o success.

Any idea?

Foi útil?

Solução

OK, it seems it is not possible to have the engine automatically replace the {{{template-parameter}}} and pass it to the extension parameters.

But, hopefully, the signature of the extension function holds a reference to the Parser object that is more or less the MediaWiki engine.

Then, you can evaluate the content of a variable:

function MyPluginRender( $input, $args, $parser , $frame)
{
    $resolved =  $parser->recursiveTagParse( $args["template-parameter"], $frame );
    var_dump($resolved);
}

HIH

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top