Page MenuHomePhabricator

TemplateData: Consider support for non-template transclusions (magic words, parser functions)
Open, HighPublic

Description

Right now it is only intended for data about custom wiki-made templates.

To support magic words and parser functions, we'll need to make a few changes to make sure there are no conflicts or wrong assumptions.

A few random points:

  • 'titles' parameter in the API module
  • The PHP parser prefers native magic word over templates (creating Template:PAGENAME and using {{PAGENAME}}, will not use that template).
  • Should there be an implied property 'type':
    • type:template -> {{Foo}}, {{:Foo}}, {{Template:Foo}}, {{Project:Foo}}
    • type:parserfunction -> {{PAGENAME}}, {{urlencode:123}}, {{#special:Watchlist}}
  • parser functions don't have numerical parameters, and the first parameter is separated by colon, not by pipe. So we need a way (both in TemplateData and VisualEditor) to insert unnamed parameters without using numbers.

    e.g. {{urlencode:Foo|WIKI}} is correct, but {{urlencode:Foo|1=WIKI}} or {{urlencode:1=Foo|2=WIKI}} or {{urlencode|1=Foo|2=WIKI}} is wrong.

Version: unspecified
Severity: normal

Event Timeline

bzimport raised the priority of this task from to High.Nov 22 2014, 1:54 AM
bzimport added a project: TemplateData.
bzimport set Reference to bz53413.

Briefly: T204371: Replace initial colon in (hash-prefixed) parser function invocation with vertical bar proposing allowing a vertical pipe to separate the first argument of a parser function, so that's not necessarily an issue. T204307: Parser Functions should support named parameters proposes allowing parser functions to opt-in to the "standard" named-argument processing such as used in templates, which I think is a better way of solving that particular problem in the long term than teaching VE/Parsoid a whole new set of serialization options.

In general I'd like to have a "parser function syntax" alternative for every extension and magic word, so that we wouldn't "need" the type parameter, we'd just always look up the various constructs in their "parser function form". The one tricky case is extensions, which do already have a parser function form in {{#tag}} but then would need an additional extension hook because {{#tag}} is used for *every* extension. It's a little awkward, because I don't "really" want to have to do dynamic dispatch on both the first argument *and* the parser function name, but I guess doing so would help with {{#invoke}} as well, so maybe I just need to support delegation.

Change 819740 had a related patch set uploaded (by C. Scott Ananian; author: C. Scott Ananian):

[mediawiki/extensions/TemplateData@master] Specification.md: Update to add parser functions and extension tags

https://gerrit.wikimedia.org/r/819740