Page MenuHomePhabricator

TemplateData: Add an "autofill" attribute for parameters which clients would automatically insert if none specified
Closed, ResolvedPublic

Description

In addition to the existing "default" attribute for each template parameter, that would be useful to have an "autofill" attribute for each template parameter:

  • "default" is the value that will be used by the template if the parameter is not specified
  • "autofill" could be used for indicating that when inserting a template in a article with VE (or other editor), some parameters should be created automatically with a given value.

I think for example of some templates that have a date parameter to be filled with the date at which the template was inserted.


Version: unspecified
Severity: enhancement

Details

Reference
bz51428

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 2:01 AM
bzimport added a project: TemplateData.
bzimport set Reference to bz51428.

This seems like a nice improvement, though I worry that it sets up an expectation that a client may not honour.

  • Bug 52028 has been marked as a duplicate of this bug. ***

From Bug 52028:
TemplateData should allow some parameters to have default values which are
prefilled when using the VisualEditor transclusion manager.

An example would be the current date for accessdate in citation templates.

I almost submitted a new bug, but saw this one in the "possible duplicates" at the last second... Pasting the text I wrote, in case it helps:

Most cleanup templates, banner and inline, have a "|date={{CURRENTMONTHNAME}} {{CURRENTYEAR}}" parameter.

If we don't add them, then (on En.Wiki) AnomieBot adds them a few minutes later*, which clutters the history, and more importantly Buries the initial edit in watchlists, making it harder for us humans to check.

*eg. https://en.wikipedia.org/w/index.php?title=Red_squirrel&curid=638291&diff=572563931&oldid=572553559

Could we have an "Add current month and year" button, for parameters like this?

Or, a tweak for TemplateData so that specific templates will add this parameter/value by default?

This is generally worked around by wikis by providing another template that when substituted inserts the autofill parameters.

e.g.

{{subst:newdelete|reason=Foo}}
->
{{delete|reason=Foo|date=YYYY-MM-DD}}

These templates need a "must-subst" property of sorts in template data first (bug 65550), but that would make this easier already.

The subst-behaviour is a super set of the scope of this bug (autofill values), however it may be enough.

The problem with a declarative autofill (as opposed to substituting a wrapper template) is that you'd need a fair amount of logic to express what you want to be filled in. Obviously you don't just want a literal string to be inserted, because then you'd just have users omit it and use that value as the default value.

With autofill you most probably want a dynamic value (e.g. the result of invoking a template, or magic words like current date/times, current revision user, base page name etc. Some of these (like date) could be trivially done, but that still leaves a lot of questions (how to specify the date etc.) and compatibility.

So I'd say let's solve bug 65550 first and see how that unfolds. If we still feel a need for this we can revisit it later.

This should additionally be helpful since subst-ing is that wikis do now without VisualEditor so they likely have that in place already and will want to keep that for wikitext users.

Change 157820 had a related patch set uploaded by Jforrester:
Implement new 'autovalue' parameter property

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

Change 157820 merged by jenkins-bot:
Implement new 'autovalue' parameter property

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