Page MenuHomePhabricator

Support "substituting" templates in transclusion dialog
Open, LowPublicFeature

Description

User:JohnCD at English Wikipedia writes the following:
"If you enter, for instance, "Welcome" in the new template box, on clicking "Apply changes" you see the result; but if you enter "subst:welcome" you see only {{subst:welcome}}, though after clicking "Save page" the result is correct. Should there be a check-box for "subst" in the New template dialogue, (a) to save typing it out, (b) to arrange the correct display?"

James F. suggested this would be good to enter as an enhancement request, since template substitution should be supported.

Maggie


Version: unspecified
Severity: enhancement
See Also:
https://bugzilla.wikimedia.org/show_bug.cgi?id=66281

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 1:43 AM
bzimport set Reference to bz49904.

Lots of important templates need subst. On en {{prod}} and {{afd}} both need to be subst.

This is effectively a subset of bug 49833 which seems to be part tracking, part bugs, part enhancement requests

(In reply to comment #2)

This is effectively a subset of bug 49833 which seems to be part tracking,
part bugs, part enhancement requests

… part mess. :-(

Not sure why you turned it into a tracker after Krinkle mis-named it; I don't think it helps at all. I might undo that.

(In reply to comment #3)

(In reply to comment #2)

This is effectively a subset of bug 49833 which seems to be part tracking,
part bugs, part enhancement requests

… part mess. :-(

Not sure why you turned it into a tracker after Krinkle mis-named it; I don't
think it helps at all. I might undo that.

Sorry, that would be my misunderstanding of Krinke's intentions and then trying to be helpful. :(

(In reply to comment #4)

(In reply to comment #3)

(In reply to comment #2)

This is effectively a subset of bug 49833 which seems to be part tracking,
part bugs, part enhancement requests

… part mess. :-(

Not sure why you turned it into a tracker after Krinkle mis-named it; I don't
think it helps at all. I might undo that.

Sorry, that would be my misunderstanding of Krinke's intentions and then
trying to be helpful. :(

Not your fault at all. :-) All fixed now, anyway.

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

Not only in insert dialogue. Template text should be inserted and rerendered page immediately.
for example:
-[[:en:Template:Accent]]
-[[:ru:Шаблон:Ударение]]

i do
-te|xt
-insert/template - subst:Ударение

i see in VE
-te{{subst:Ударение}}xt
(after saving the page text in read mode looks normally: téxt)

I want to see in VE
-téxt

if possible it should be a new method "template (with parameters) to text ()" with no return to template
for example:
-"insert/subst" or "insert/template" and in dialogue check-box for "subst"
-open TemplateData for "template" (now for "subst:template" TemplateData not shown)
-press Add template
-template is executed and generate new text which is inserted same as ctrl+v
-the new text (or all page) rendered (may consist any other template inside it)

Subst:ing isn't working (again? still?).

If you follow the (soon-to-be-blanked) directions in the user guide, you get the text typed in, with no display, no expansion, and no processing. The result is that the exact wikitext of your template displays on the page, exactly as if it had been nowiki'd, but without the nowiki tags.

https://en.wikipedia.org/w/index.php?diff=620566012&oldid=618729009

Change 153895 had a related patch set uploaded by Alex Monk:
Add a subst property to template data which adds "subst:" to the target

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

Change 153934 had a related patch set uploaded by Alex Monk:
Provide a checkbox on template page of transclusion dialog to substitute when saving

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

Change 153895 abandoned by Alex Monk:
Add a subst property to template data which adds "subst:" to the target

Reason:
I'm not actually planning to work on this commit. The associated VE commit will continue to depend on this however.

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

Jdforrester-WMF renamed this task from VisualEditor: Support "substituting" templates in transclusion dialog to Support "substituting" templates in transclusion dialog.Nov 24 2014, 1:47 AM
Jdforrester-WMF assigned this task to Krenair.
Jdforrester-WMF lowered the priority of this task from Medium to Low.
Jdforrester-WMF moved this task from TR6: Visual diffs to Blocked on the VisualEditor board.
Jdforrester-WMF set Security to None.
Krenair edited projects, added Parsoid; removed Patch-For-Review.

I'm not sure the parsoid API from T73161 is quite what we were looking for. The idea had been to allow the user to mark a template to be substituted upon save, but with this we'd have to substitute an entire transclusion (immediately?)

I'm not sure the parsoid API from T73161 is quite what we were looking for. The idea had been to allow the user to mark a template to be substituted upon save, but with this we'd have to substitute an entire transclusion (immediately?)

But, whenever a user edits a transclusion, you are querying the API to fetch the expansion. So, you would enable the subst parameter alongwith the query instead of marking up individual transclusions for 'at-save' substitution. Once substed, the transclusion itself goes away and the editor can further tweak that output if required.

But yes, you would have to substitute transclusions immediately, rather than "on-save" as with the wikitext PST mode of operation.

Substituting things directly on the client? That sounds like we'd run into more issues involving unbalanced html fragments?

Substituting things directly on the client? That sounds like we'd run into more issues involving unbalanced html fragments?

Yes, subst directly on the client. In VE, as far as I understand, you cannot add transclusions that generate unbalanced HTML since you have to ask Parsoid for an expansion and you get balanced DOMs always.

So, as far as I can imagine, this subst feature in VE will have to be in-edit substitution of DOMs rather than on-save substitution of arbitrary wikitext.

If I have misunderstood this feature and how it would work inside VE, then we should talk more on IRC sometime to get clarity about how this would / should work and update it here, and we can make appropriate updates to the API.

I'm not sure the parsoid API from T73161 is quite what we were looking for. The idea had been to allow the user to mark a template to be substituted upon save, but with this we'd have to substitute an entire transclusion (immediately?)

If you look at this task's description, it asks for being able to do a subst when inserting a template from the template dialog box. Also, according to the description, susbt already works when saving.

New feedback concerning that task (here, need to subst: a date on a template included with VE).

ssastry added subscribers: JTannerWMF, Esanders, matmarex.

Parsoid's API supports substing. But, VE folks need to figure out what they exactly need to support user feature requests. I'm going to untag Parsoid here. @Esanders @matmarex @JTannerWMF: please take a look and retag Parsoid with an updated description if you need anything from us.

Am I right in understanding that this ticket seeks to make it possible to use subst when adding a template to a page in VisualEditor, or is that another task?

Yes, that's the goal. There is no timeline for when the work might be done.

Aklapper changed the subtype of this task from "Task" to "Feature Request".Feb 4 2022, 11:13 AM
Aklapper removed a subscriber: rmoen.

Change 855565 had a related patch set uploaded (by Daniel Kinzler; author: Daniel Kinzler):

[mediawiki/core@master] ParsoidHandler: remove subst feature from wt2html

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

For context about this patch: @daniel discovered that feature in Parsoid while doing some refactoring, and we discovered that we were not using it. All it does is to add subst: to template invocations, before calling existing APIs for pre-save transform and for parsing. That doesn't seem useful even if we wanted to add substing templates to VE (we could easily add this prefix and call the APIs ourselves).

We're not planning to work on this task apart from this at the moment. The main obstacle is designing the interface so that people wouldn't damage articles by using it without understanding what it does.

Change 855565 merged by jenkins-bot:

[mediawiki/core@master] ParsoidHandler: remove subst feature from wt2html

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

@matmarex , the unsubst module can be used in most cases to prevent inexperienced editors from accidentally using substitution erroneously. Beyond that, a better version of TemplateData would allow for instruction about substitution for each template.

For now, I think allowing substitution in VE is still a worthwhile goal, even if it has to remain a somewhat advanced/hidden feature to avoid improper use.