Jump to content

Topic on Help talk:Substitution/Flow

Summary by Retro

Substitution can only be applied to a template by using subst:; it can't be implicitly inferred when transcluding a template. On the English Wikipedia, certain templates are automatically substituted by bots.

أحمد (talkcontribs)

I have been re-reading this for a year now and I must be very thick because I'm unable to answer a very basic question:

Is it possible to create a template T that, when included normally in page P, would substitute some of its output in page P?

alternatively:

Is it possible to create a template T1 that, when included normally in page P, would substitute the output of another template T2 in page P?

I.e is it possible to hide the mechanics of substitution of the layuser who would continue to use templates as they normally would?

RobinHood70 (talkcontribs)

While I'm no substitution expert, I'm reasonably sure the answer is "no" to both of these. The end user has to decide whether they're substituting or not; after that, however, a template can certainly control how it responds to a request to be substituted (or if it's not substituted but should be).

Retro (talkcontribs)

I'm no substitution expert either, but I concur the answer is "no" based on discussion I've seen elsewhere and my general intuition about how the wikitext parser works.

The issue come down to the very nature of substitution. subst: is special because it gets processed earlier than anything else. subst: can't be added on a page through transclusion, because the text containing subst: would be expanded later in the page parsing process, thus ineligible to be interpreted as a proper substitution. Therefore it seems that the only way to trigger a template substitution is explicitly by the editor using the template.

However, this not mean there can't be multi-level cascading substitution; I believe it is possible for a template that is marked with subst: to trigger templates it uses to subst: as well.