Page MenuHomePhabricator

Fix numbered parameters to not include the number
Closed, ResolvedPublic5 Estimated Story Points


Numbered/unnamed parameters are being inserted with the number: {{tpl|1=lorem}}

This should be fixed.

Note: TemplateMaster handles this correctly.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Niharika set the point value for this task to 5.

If you don't mind an extra API call, you could instead build Parsoid DOM, and have Parsoid generate the wikitext for you. This would not only fix this bug, but allow you to remove a bunch of wikitext escaping code you may have, as well as all the formatting code (block/inline/custom) as Parsoid reads the format from the TemplateData API. defines the markup, but all you need to generate is a single element (e.g. span) with two attributes:


Where data-mw is the JSON encode of:

  parts: [ { template: {
    target: { wt: "Infobox" },
    params: {
      Foo: {"wt": "bar"},
      baz: {"wt": "quux"}
  } } ]

If you send the above HTML to Parsoid you will get back

 | Foo=bar
 | bazz=quux

with numbered params handled correctly, and the correct formatting applied. It will also do value escaping, such as | -> {{!}} or { -> <nowiki>{</nowiki>

Change 424205 had a related patch set uploaded (by Samwilson; owner: Samwilson):
[mediawiki/extensions/TemplateWizard@master] Handle unnamed parameters

Samwilson edited projects, added Community-Tech-Sprint; removed Community-Tech.

@Esanders this is a good idea, and would certainly make some things a bit simpler. However, after discussion, we've decided to at least try to avoid a dependency on Parsoid. This is mainly because we want to be able to support 3rd party MediaWiki installations, and not many of them have Parsoid installed. Also, the (possible?) future shifting of Parsoid to be in core or at least in PHP adds a bit of uncertainty (although, I guess the API endpoints wouldn't change, so that's maybe less of a worry). We'll of course re-visit this if it seems we're going down a long tail of annoying bugs! :-)

So I've taken a first stab at a patch to support unnamed parameters. One thing I'm not sure about is how block formatting should be handled? Perhaps it's a pretty rare case that we can not worry about too much. At the moment it'd look something like this if there are three unnamed parameters and only the third is given:

{{Infobox person
|   Third unnamed param
| name = test

and not many of them have Parsoid installed

I imagine fewer have TemplateData installed?

One thing I'm not sure about is how block formatting should be handled?

That's probably right, you can test with Parsoid to see what they do...

I'd say TemplateData is much easier to install and use for a third party wiki than Parsoid is. We can definitely switch to using Parsoid if we discover more edge cases that we can't handle easily or we feel like that we're reinventing the wheel.

Change 424205 merged by jenkins-bot:
[mediawiki/extensions/TemplateWizard@master] Handle unnamed parameters

Niharika moved this task from Needs Review/Feedback to Q1 2018-19 on the Community-Tech-Sprint board.

I feel a bit conflicted on parsoid's output there (as described by Ed on the gerrit ticket) mainly because I haven't seen that anywhere on wiki before. We'll come to know if people complain.