Reputation: 219
Consider a custom MediaWiki extension that adds a new tag named simplified_example
with some JavaScript (just calling alert
with provided argument for simplicity):
<?php
if ( ! defined( 'MEDIAWIKI' ) ) die();
$wgExtensionFunctions[] = 'registerTags';
$wgExtensionCredits['parserhook'][] = array(
'name' => 'myTags',
);
function registerTags() {
global $wgParser;
$wgParser->setHook('simplified_example', function ($input, $argv, $parser, $frame) {
$output = $parser->recursiveTagParse($input, $frame);
$title = $argv["value"];
return "<div onclick=\"alert('$title')\">$output</div>";
});
}
?>
Using that I can put following code in a MediaWiki page source:
<simplified_example value="Testing">...</simplified_example>
This results with ...
div being clickable - a message box with provided text is displayed. Now I wanted to place this tag inside a template, like this:
<simplified_example value="{{{1}}}">...</simplified_example>
When I put this template into a MediaWiki page:
{{TestTemplate|Testing...}}
Once again I obtain a clickable ...
but displayed message is not evaluated and {{{1}}}
is displayed instead of provided Testing...
.
How can I pass the argument from MediaWiki page source down to my custom tag through a template?
Upvotes: 0
Views: 422
Reputation: 613
Try to use #tag
function instead of html in your template, like this:
{{#tag:simplified_example|value={{{1}}} }}
Upvotes: 3