On Wed, 06 Jun 2007 14:36:19 -0500, Jim Wilson wrote:
Or you could parse the content before doing anything with the <tag> content. One of the hook parameters is the parser you should use to replace templates.
I think he's talking about params like {{{1}}}, not processing a transclusion request {{like this}}. But even so, a parser function is a more elegant solution to either of these as it happens "in line" with all the benefits of being integrated into the parser during that earlier pass.
Extension tags happen "outside" template processing, so mixing the two is kind of a strange thing in practice.
Extension tags are supposed to return HTML, and don't necessarily have wiki input. If they have wiki text, they can use $parser->recursiveTagParse() to parse it.
If you just want to substitute parameters in a tag function, you'd need to pass arguments to the tag, then replace them in the text i.e.
<tag param=val> text {{{param}}} </tag>
function MyTag ($in, $params, $parser) { $text = $parser->replaceVariables($in,$params); ...
Which wouldn't parse, just replace the args with a (techincally private) parser method.
To parse arguments from a parser function, you'd only need to return an array of arguments and the right combination of flags to parse them.
-- Jim
On 6/6/07, Platonides Platonides@gmail.com wrote:
Parser functions don't substitute template arguments either. To do that
you'd have to get the argument array from the call, call $parser->createAssocArgs($args) to parse it, and return the result
Jim Wilson wrote:
Hi Nils,
Two things:
- You're correct that extension tags don't expand template parameters.
What you'd want is what's called a parser function [1] [2].
- You may want to have a look at Semantic Forms - there's a chance it
may
already do what you want (or perhaps at least a portion thereof) [3].
Or you could parse the content before doing anything with the <tag> content. One of the hook parameters is the parser you should use to replace templates. See mediawiki-l archives.
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/wikitech-l