Add support for actual format strings to TemplateData's "format" parameter
Closed, ResolvedPublic8 Story Points

Description

I suggest to extend the existing "format": "…" parameter of <templatedata> to not only accept inline and block but an actual format string (or add a new parameter for that). Typical format strings would look like these:

  • |_=_ is the same as inline.
  • | _ = _\n is the same as block.
  • |_ = _\n does not add a space before the parameter name.
  • |_ = _\n indents each parameter.
  • |_______________ = _\n aligns all parameter names to that length. Or more if the parameter name is longer (it can not be cut, obviously), but will always have spaces before and after the equal sign.
  • |\n_ = _ is a format with the pipe characters at the end of the previous line.
  • |_ = _ is an inline style with much more spaces.

I'm currently using this format in my Auto-Formatter wikitext cleaner, see de:User:TMg/autoFormatter #Vorlagenformatierung for the documentation and de:User:TMg/autoFormatter.js for the (ugly) code. More examples can be found at the bottom of my de:User:TMg/common.js.

There are "magic" edge cases my tool considers:

  • |_=_ is the minimum that must be in the format string. My tool adds missing elements. TemplateData should output an error if something is missing.
  • If the format string ends with a newline, an extra newline is added between the template name and the first parameter.
  • If there is a newline somewhere in the format string, the closing }} is always put on an extra line, no matter what the format string says. My tool makes sure to never create duplicate newlines.
  • Spaces on line endings are allowed. For example, |_ = _\n means there will be a space at the end of the line when the parameter is empty.
  • A single _ does not create an extra space when the parameter is empty.
Restricted Application added subscribers: Zppix, Aklapper. · View Herald TranscriptJun 23 2016, 1:16 PM

Absolutely not, as we outlined before.

Change 295741 had a related patch set uploaded (by Cscott):
Use improved format specifier for TemplateData.

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

This probably needs to specify whether the template has to sit on its own line or inline (e.g. nlwiki's {{largethumb}} breaks if on its own line, and enwiki's {{s-bef}} breaks if not), and possibly as the same state or as its own whether it should (e.g. {{Use American English}}\n{{Use MDY dates}}\nContent here.)

Jdforrester-WMF triaged this task as Low priority.Jun 29 2016, 4:35 PM
Jdforrester-WMF removed a project: RfC.
Jdforrester-WMF set the point value for this task to 8.
Ltrlg added a subscriber: Ltrlg.Jul 3 2016, 5:04 PM

This probably needs to specify whether the template has to sit on its own line or inline (e.g. nlwiki's {{largethumb}} breaks if on its own line, and enwiki's {{s-bef}} breaks if not), and possibly as the same state or as its own whether it should (e.g. {{Use American English}}\n{{Use MDY dates}}\nContent here.)

Specifically, that would be T135667: Please put templates on separate lines (when it won't break things) and don't (when it will).

@thiemowmde : could you look at @Jdforrester-WMF's request (T135667: Please put templates on separate lines (when it won't break things) and don't (when it will)) and perhaps suggest some way of doing this with your "format" parameter? Perhaps we just need a new parameter to <templatedata>, but if there's some way of doing this with the format string, it would avoid inventing more parameters...

Change 303431 had a related patch set uploaded (by Cscott):
WIP: Extend 'format' spec to include format strings.

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

Change 306975 had a related patch set uploaded (by Cscott):
Extend 'format' spec to include custom format strings.

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

Change 303431 abandoned by Cscott:
Extend 'format' spec to include custom format strings.

Reason:
Abandoned in favor of https://gerrit.wikimedia.org/r/306975

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

Elitre added a subscriber: Elitre.Sep 9 2016, 9:33 AM
Pols12 added a subscriber: Pols12.Oct 23 2016, 1:01 PM
Jdforrester-WMF moved this task from Backlog to Doing on the TemplateData board.Nov 22 2016, 8:13 PM

Change 306975 merged by jenkins-bot:
Extend 'format' spec to include custom format strings.

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

The change to add this to TemplateData is now merged; I'll wait to mark this Resolved once the use of the new support is merged in Parsoid (https://gerrit.wikimedia.org/r/#/c/295741/).

Change 295741 merged by jenkins-bot:
[mediawiki/services/parsoid@master] Use improved format specifier for TemplateData.

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

Jdforrester-WMF closed this task as Resolved.Oct 11 2017, 7:25 PM

This has been complete in TD for 10 months, and Parsoid support is rolling out very soon. Declaring this Resolved.

Restricted Application added a project: User-Ryasmeen. · View Herald TranscriptOct 11 2017, 7:25 PM

Mentioned in SAL (#wikimedia-operations) [2017-10-11T20:22:05Z] <subbu> updated Parsoid to ddf7b293 (T138492, T135667, T177612)