Last modified: 2011-07-18 18:04:31 UTC
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>
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>.
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]]).
Created attachment 2584 [details] probably the only thing needed to be done
Comment on attachment 2584 [details] probably the only thing needed to be done didn't test the path, this one is minor wrong, next one is correct
Created attachment 2585 [details] correct path This is the correct version of the patch, tested on local wiki
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.
(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.
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.
Comment on attachment 2585 [details] 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. ***
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:
Reverted by Tim in r62689. Branched to http://www.mediawiki.org/w/index.php?title=Special:Code/MediaWiki/path&path=%2Fbranches%2Fconrad
This change was not reverted, so re-closed as comment 13