Hi,
I'am writing a tag extension which declares several tags.
When with <sample>...</sample>
function renderTagSample( $input, array $args, Parser $parser, PPFrame $frame ) { ... }
is called is there a way to get the tag name "sample" itself inside renderTagSample?
Thanks in advance
Sigbert
Hi,
I think I had a similar problem. I solved it by using just one tag, and added an "action" param.
<sample action=dojobxxx>...</sample>
In "renderTagSample" you can then check the "action" arg and switch to the job you want to do...
Hope this helps. Greetings Frank
On 05.03.2016 10:35, Sigbert Klinke wrote:
Hi,
I'am writing a tag extension which declares several tags.
When with <sample>...</sample>
function renderTagSample( $input, array $args, Parser $parser, PPFrame $frame ) { ... }
is called is there a way to get the tag name "sample" itself inside renderTagSample?
Thanks in advance
Sigbert
MediaWiki-l mailing list To unsubscribe, go to: https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Hi,
this it how I did it till now, but it is uncomfortable for the user. Currently I intended for each tag to dynamical create a unique class which just have one static renderSample function and in there I just call another renderSample function with an additional tag parameter. But I hope that the $parser could tell me which tag is currently parsed.
Thanks Sigbert
On 05.03.2016 13:50, Frank Baxmann wrote:
Hi,
I think I had a similar problem. I solved it by using just one tag, and added an "action" param.
<sample action=dojobxxx>...</sample>
In "renderTagSample" you can then check the "action" arg and switch to the job you want to do...
Hope this helps. Greetings Frank
On 05.03.2016 10:35, Sigbert Klinke wrote:
Hi,
I'am writing a tag extension which declares several tags.
When with <sample>...</sample>
function renderTagSample( $input, array $args, Parser $parser, PPFrame $frame ) { ... }
is called is there a way to get the tag name "sample" itself inside renderTagSample?
Thanks in advance
Sigbert
MediaWiki-l mailing list To unsubscribe, go to: https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
MediaWiki-l mailing list To unsubscribe, go to: https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Sigbert Klinke asks about <sample>:
is called is there a way to get the tag name "sample" itself inside [a tag extension]?
I am pretty sure the answer is no. I worked around it by defining my callbacks dynamically, one per tag.
Suppose you are writing 3 tags named <A>, <B>, and <C>. You can dynamically create a callback function for each one, passing the tag name to it, something like this:
public static function initTags(Parser &$parser) { foreach (array('A', 'B', 'C') as $tagName) { $callback = function($argv) use ($tagName, $parser) { return Tags::processTag($tagName, $argv, $parser); }; $parser->setHook($tagName, $callback); } return true; }
Now the function processTag() knows the tag name, and you can write it to do whatever you want.
DanB
I have now documented my solution (how to obtain the tag name inside of the tag callback) at
https://www.mediawiki.org/wiki/Manual:Tag_extensions#Retrieving_the_tag_name...
DanB
mediawiki-l@lists.wikimedia.org