[go: up one dir, main page]

Page MenuHomePhabricator

templatedata - allow "custom" attributes
Open, Needs TriagePublic

Description

so templatedata holds all the metadata pertaining to specific template, and is supposed to describe all its parameters.

over the years, some creative use was made in wikitext templates, and it's not realistic to expect the "canonical" definition of templatedata to support them all. i will list a couple of such examples at the bottom to the ticket.

mediawiki guards the attributes of templatedata zealously, and some gatekeeper code makes it impossible to save a template page containing any templatedata attribute (or value, for that matter) not in the sanctified list.

the committee defining the html standard was facing similar challenge, and they came up with a solution that i think will help us too: basically, an attribute must be one of a closed and finite list of "kosher" attributes, and adding to html element any attribute not in the list is considered an error.
however, to retain some flexibility, any attribute matching regex "data-.*" is allowed. IOW, the "whitelist" of legit attributes contains at least one "pattern" that can match unlimited number of different attributes.

this request is to allow any attribute (at least in the "params" list), whose name adheres to some pattern. i weakly suggest "custom-.*", but TBH any provision for "custom" or "private" attributes will do.

it is possible to extend the "canonical" definition or templatedata to support the examples below (and i'll be the first to cheer when this happens), but i doubt it is practical to cover every useful attribute, mainly thanks to the creativity of template authors and scribunto coders. i'm asking for a "loophole" a-la "data-" in html.

EXAMPLES:

  • thanks to scribunto, many templates allow a series of parameters distinguished by numeric tail: x1, x2, x3...x<N> where N is unbounded - the module parsing the template knows what to do
  • some templates pass the parameter value to a {{#switch, where the "default" clause denotes an error: it would be nice to list the "legit" values in templatedata, for "template linters" and template wizards, and other tools
  • interdependence: in some template, a parameter becomes "required" when another one is non-empty, or the opposite: it may become "forbidden" when another is not empty
  • if it helps, i could probably come up with another half-dozen or so imagined attributes to templatedata that would help with real-life problems, but i'd rather have the blanket "custon-.*" whitelist

peace

Event Timeline

Restricted Application added subscribers: Liuxinyu970226, Aklapper. · View Herald Transcript
ppelberg subscribed.

Thank you for taking the time to lay out this suggestion, @Kipod.

Are you able to share what prompted you to suggest this? Asked another way: when are you constrained by this current limitation of templatedata?

In asking the above, I'm trying to better understand what the impacts might be of allowing "custom" attributes in templatedata.