Page MenuHomePhabricator

Have VisualEditor identify "subst:-only" templates
Open, Needs TriagePublicFeature

Description

Feature summary (what you would like to be able to do and where):

I would like the VisualEditor to identify when a template is designed to be used by substitution only (not by transclusion), so that when adding it, it will also add subst: to the template name. This way, when the page is saved, the template code will be substituted into it.

Use case(s) (list the steps that you performed to discover that problem, and describe the actual underlying problem which you want to solve. Do not describe only a solution):

Many templates are designed for use by substitution only (not by transclusion). When using the VisualEditor, the search box finds these templates, but when selected they are added like any other template, by transclusion (no subst: is added to the wikicode).
Today, to substitute such a template using the VisualEditor, one has to use the "subst: hack", i.e. type "subst:" followed by the template name in the search box, DON'T select the template from the suggestion list, and click the "add" button. However, this hack is not user-friendly, and it would be very helpful to have the option to use these templates the way they are designed to be used built into the interface. If the editor could identify such templates in some way (by being in the category I linked to above, or by a template stating this in their documentation page, or some marking in the templatedata json code, or a magic word, or any other way), it would be great.

Benefits (why should this be implemented?):

In the last link above, it is stated that "most users won’t ever need to resort to substitution." I agree that in most template-adding *edits*, there is no need for substitution. But there are some very widely used substitution-only templates, which are relevant to many users; and there are groups of users (aged people, for example) who don't know how to edit wiki source code, and the VisualEditor is their only usable editing tool. Currently, when they need to use these templates they either ask for help, or do it wrongly. It would be great if the editor itself could add the templates correctly with the user performing the usual procedure, with no need for any hack.

Event Timeline

Probably depends on T4003: Add marker that forces a template to be always substituted or something similar. There's been other discussion about supporting auto-substing here and there (I think in the context of the former Community Wishlist) that would probably need to be considered in either context.

T4003 would force the parser to always subst. This could be probably be handled in the editor if had a marker in template data which was filed as T67550.

Thanks a lot to both of you!
@Izno - after your comment I found this wishlist survey discussion, perhaps the one you referred to. Just thought to link to it from here.
I agree with @Esanders that this specific feature can be implemented with less side effects by making the visual editor recognize the templates and add the subst: wikicode, instead of assigning this task to the parser.
One small thing I forgot to mention earlier (relevant to all of these suggestions, I guess): in other languages there are local translations for subst:, so this feature should also have some kind of internationalization.

T4003 would force the parser to always subst. This could be probably be handled in the editor if had a marker in template data which was filed as T67550.

My assumption was that T4003 would be implemented in terms of TemplateData at this point (or perhaps a slot, but I think TemplateData would also be a clear subsumption into a slot now also, barring questions like I've posed elsewhere about how/whether slots transclude).