W3TPL/tags: Difference between revisions
No edit summary |
No edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
Line 13: | Line 13: | ||
|- | |- | ||
| valign=top | | | valign=top | | ||
===Supported=== | |||
* {{l/w3tpl/tag|dump}} | |||
* {{l/w3tpl/tag|echo}} | |||
* {{l/w3tpl/tag|get}} | |||
* {{l/w3tpl/tag|hide}} | |||
* {{l/w3tpl/tag|let}} | |||
===Unsupported=== | |||
These tags have been written but not checked with current versions of MediaWiki and PHP; they may not work. | |||
* {{l/w3tpl/tag|arg}} | * {{l/w3tpl/tag|arg}} | ||
* {{l/w3tpl/tag|call}} | * {{l/w3tpl/tag|call}} | ||
* {{l/w3tpl/tag|else}} | * {{l/w3tpl/tag|else}} | ||
* {{l/w3tpl/tag|for}} | * {{l/w3tpl/tag|for}} | ||
* {{l/w3tpl/tag|func}} | * {{l/w3tpl/tag|func}} | ||
* {{l/w3tpl/tag|if}} | * {{l/w3tpl/tag|if}} | ||
* {{l/w3tpl/tag|load}} | * {{l/w3tpl/tag|load}} | ||
* {{l/w3tpl/tag|save}} | * {{l/w3tpl/tag|save}} | ||
Line 59: | Line 61: | ||
* '''parse''': parse any wikitext when reading the value of a variable | * '''parse''': parse any wikitext when reading the value of a variable | ||
==Technical Notes== | ==Technical Notes== | ||
At startup, the hook for each tag is initialized: | |||
* $mwoParser->setHook( {{arg|tag name}},{{arg|tag class}}::Call() ) | |||
The content-processing flow for tags goes like this: | The content-processing flow for tags goes like this: | ||
* | * {{arg|tag object}}->Call() | ||
* &rarr | * → {{arg|tag object}}->Setup((string) $sInput,$arArgs,$mwoParser,$mwoFrame); | ||
* | * → return {{arg|tag object}}->FigureReturnValue() | ||
** → $sOut = $this->Go(); // $sOut gets a bit of extra processing and is eventually returned | |||
*** → $sIn = $this->GetTagInput(); | |||
*** → $sOut = $this->UseTagInput($sIn); | |||
*** → return $sOut; | |||
GetTagInput() and UseTagInput() are then specialized by the various tag classes. | |||
Latest revision as of 21:09, 1 May 2022
About
W3TPL implements a set of XML-style tags for embedding within wikitext, and uses the MediaWiki parser (via a standard hook) to notice them and call the appropriate W#TPL code for processing.
The MW parser does not always do things in the expected order, so most of these tags have ways of using internal data for their values rather than depending on the literal sequencing of the tags.
Another issue with the MediaWiki parser is that it cannot deal with nested tags properly; the ending-tag of a tag-pair nested inside another tag-pair results in closure of the outer tag-pair as well, and any text past the internal closing-tag is displayed rather than being passed to the tag handler. W3TPL allows you to get around this limitation by defining functions which are parsed separately from the code-block in which they are executing.
My plan has been to create a <w3tpl> content-tag which supports directly-parsed scripting, based on the names and attributes of the existing W3 tags.
Tags
alphabetical | by function |
---|---|
SupportedUnsupportedThese tags have been written but not checked with current versions of MediaWiki and PHP; they may not work. |
|
Common Attributes
- name=: name of variable being accessed (usage depends on tag)
- hide: if present, the contents of the tag will not be displayed except for those enclosed by <echo> tags. If absent, the contents of the <echo><echo> tags are ignored and only the remainder of the content is shown. (At present, contents of the <hide> tag itself are never displayed; this will be changed to enable the <echo> tag at some point.)
- parse: parse any wikitext when reading the value of a variable
Technical Notes
At startup, the hook for each tag is initialized:
- $mwoParser->setHook( <tag name>,<tag class>::Call() )
The content-processing flow for tags goes like this:
- <tag object>->Call()
- → <tag object>->Setup((string) $sInput,$arArgs,$mwoParser,$mwoFrame);
- → return <tag object>->FigureReturnValue()
- → $sOut = $this->Go(); // $sOut gets a bit of extra processing and is eventually returned
- → $sIn = $this->GetTagInput();
- → $sOut = $this->UseTagInput($sIn);
- → return $sOut;
- → $sOut = $this->Go(); // $sOut gets a bit of extra processing and is eventually returned
GetTagInput() and UseTagInput() are then specialized by the various tag classes.