Page MenuHomePhabricator

ParsoidExtensionAPI: Provide a new method for extensions to access enclosing template parameters
Open, Needs TriagePublic


See discussion in

Consider a template {{my-template}arg1}arg2 .. |argn}} whose implementation includes an extension tag: <ext>... value-of-arg1 .. value-of-arg2 .. </ext>. So, the extension's tag handler might need access to enclosing transclusion's parameters.

We should either pass these through the sourceToDom API method or provide a separate method for extensions to query.

Event Timeline

An attempt at this was started in,

but was reverted because of T301948, T302007, and T301986

This is going to depend on T301080 because Parsoid currently collapses all the frames so only template arguments from the first level of the expansion are available. Extension tags nested a few templates deep wouldn't see the right arguments.

Your memory and history is much better than mine even though I wrote those patches originally!! :-)

One proposal is for all parsing to take place in the context of a "data object", which would include both explicit (typed) parameters as well as a "data object", possible associated via wikibase query or some such. Some notes:

  • T348722 has a proposal by Tim Starling for attaching data to the <section>
    • T230658 proposes syntax for “section attributes”, potentially something similar could use used to set section data ala Tim’s proposal?
  • SMW and {{#set}} are discussed in T122934#9196348


  • avoid “from point of definition” behavior for {{#set}}-type data declarations.
  • Avoid exposing entire frame stack implicitly to templates; instead pass data explicitly so dependencies are manageable.

Thanks @Alex44019 and @cscott for raising this one. I remember discussing it with the team a while back, but the Parsoid extension API was considerably less fleshed out back then.