Yauhen
Yauhen

Reputation: 71

Mediawiki process tag after templates tranclusion

Is there any way to do something like that. I have next wiki text:

{{template_open_tag}}
{{template_some_data}}
{{template_close_tag}}

And there are templates:

{{template_open_tag}}

<my-tag>

{{template_some_data}}

bla-bla-bla...

{{template_close_tag}}

</my-tag>

But tag '<bold>' processed already when first template transluded and wiki render this page like:

bla-bla-bla...
</my-tag>

But I want to see:

**bla-bla-bla...**

In my extension:


$wgHooks['ParserFirstCallInit'][] = 'myTagInit';

function myTagInit( &$parser ) {
   $parser->setHook( 'my-tag', 'myTagRender' );
}

function myTagRender( $input, $args, $parser, $frame) {
   return "**".$input."**";
}

Thank you.

P.S. And don't ask me why I need this strange markup and don't want to use something like this:

{{template_tag|{{template_some_data}}}}

And {{template_open_tag}} like:

<my-tag>{{{1}}}</my-tag>

Upvotes: 0

Views: 220

Answers (3)

Brion
Brion

Reputation: 1041

To warn you -- this sort of structure will likely be phased out entirely in future versions of MediaWiki, due to its inconsistent behavior and the difficulties it causes with structures like tags and sections.

The correct and future-proof way to do it is indeed to contain both your start and end in one template and pass the middle in as a parameter, eg {{template_tag|{{template_some_data}}}}

Upvotes: 2

Tgr
Tgr

Reputation: 28220

Set $wgUseTidy to true to make MediaWiki remove unclosed tags only after all the templates have been evaluated. Alternatively, you can use wikimarkup - as Adrian said - which does not suffer from this limitation.

Update: AFAIK XML-style extension tags are evaluated before way template including happens, so piecing them together from multiple templates is not possible. (Event <ext>{{{1}}}</ext> does not work pre-1.16, though you can make it work in 1.16 with recursiveTagParse.)

Upvotes: 1

Adrian Archer
Adrian Archer

Reputation: 2323

instead of using <bold> use ''' in both your {{template_open_tag}} and {{template_close_tag}} and it should render as bla-bla-bla...

Also, you can't do:

{{template_open_tag}}
{{template_some_data}}
{{template_close_tag}}

You have to do

{{template_open_tag}}{{template_some_data}}{{template_close_tag}}

Upvotes: 0

Related Questions