Page MenuHomePhabricator

<substonly> and <nosubst>
Closed, DeclinedPublic

Description

I would like to propose an enchantment simlar to includeonly and noinclude, but
trigger on subst instead.

Example:
{{<onsubst>subst:</onsubst>template}}<nosubst>[{{SERVER}}{{fullurl:{{PAGENAME}}}}|action=edit]</nosubst>


Version: 1.9.x
Severity: enhancement

Details

Reference
bz4484

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 9:00 PM
bzimport set Reference to bz4484.
bzimport added a subscriber: Unknown Object (MLST).

rmcardle wrote:

I'd like to second that request. I think <substonly> instead of <onsubst> would be better though, to keep the
syntax the same as <includeonly>.

omniplex wrote:

Today I tried...
<includeonly<noinclude>[[Category:foo]]</noinclude></includeonly>
...in a template used by other templates, which should be in the
template category foo, but pages using those other templates are
no foo-templates. That experiment failed miserably, is it related
to this report?

First of all, the opening tag should be "<includeonly>", not "<includeonly".
Second of all, no, this bug report is requesting a way to include code only when
substituting ([[m:Help:Substitution]]).

probably the only thing needed to be done

attachment subst.patch ignored as obsolete

Comment on attachment 2584
probably the only thing needed to be done

didn't test the path, this one is minor wrong, next one is correct

correct path

This is the correct version of the patch, tested on local wiki

attachment subst.patch ignored as obsolete

Behavior should never be different between straight inclusion and subst; strongly
inclined to WONTFIX this.

If there are problems with subst behavior, these should be found, reported, and
addressed specifically.

ayg wrote:

(In reply to comment #7)

Behavior should never be different between straight inclusion and subst; strongly
inclined to WONTFIX this.

If there are problems with subst behavior, these should be found, reported, and
addressed specifically.

The first that comes to mind that we probably don't want to fix is that substed
headers act like normal headers, transcluded headers have a section edit link
going back to their template. This causes problems on any number of templates,
like [[Template:Imagesource]] on enwiki, that are generally dumped on the user
talk pages of newbies who will then attempt to edit the section to respond. The
templates are supposed to be substed anyway (see bug 2003), but if someone
doesn't, then you don't want to have to protect a low-risk template for such a
silly reason. It would also be useful for seamless template-side implementation
of bug 2777, so that the user doesn't have to use a different word just because
the template happens to contain some other templates or whatever. And probably
other things as well.

In general, this feature is emulated right now via abuse of bug 5453, possibly
among other behaviors that might be undefined or subject to change or just messy.

titoxd.wikimedia wrote:

At first glance, having different behavior on substitution and transclusion
sounds like a bad idea, but there are several uses for this, particularly
phasing out the abuse of bug 5453. I just spend about 20 minutes trying to fix
[[Template:Class parameter]], which is a meta-template used to add a particular
function to WikiProject banners on the English Wikipedia. It is much better to
tell someone "add the following line of code here:" than "add the following
block of code and replace every single appearance of 'blah' for something else",
and the way we accomplish it is via an extremely ugly hack, which renders the
code unreadable and makes babies cry. A {{substonly:}} function could be used
for easier integration of these metatemplates, and could also be used to shrink
the awful [[Template:Afd]] and others.

ayg wrote:

Comment on attachment 2585
correct path

Obviously, the patch is no longer remotely applicable with the Parser changes ("noinclude" doesn't even occur in Parser.php except in a comment).

Just to add my STRONGEST support for this feature. Right now, I'm fighting with including an optional parameter to [[en:Template:Afd top]] that should work when both transcluded and substed. As it is now, I can't subst parser functions when transcluding; all the parser code is transcluded instead. Likewise, when NOT substing parser function, the template exposes the function code in the wiki source when substed, which breaks bots. A simple <substonly>subst:</substonly>(parser function) would fix these two major problem at the same time.

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

conrad.irwin wrote:

Since safesubst: was added in r61710. You will be able to use "safesubst:"
instead of "subst:" in templates that require both transclusion and substitution to work. As this is the main use-case of <nosubst> and <substonly>, this should be good enough.

If you need more behaviour it is possible to tell whether the template has been substituted or not using the behaviour of "subst:", though I'll agree this is a bit hacky.

{{ {{{|safesubst:}}} #if: {{subst:ns:0}} | nosubst | substonly }}

http://en.wikipedia.org/wiki/Help:Substitution#safesubst:

conrad.irwin wrote:

This change was not reverted, so re-closed as comment 13