Last modified: 2010-02-10 15:11:24 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T13670, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 11670 - Deferred template substitution (with some magic keyword such as subst1)
Deferred template substitution (with some magic keyword such as subst1)
Status: RESOLVED DUPLICATE of bug 22297
Product: MediaWiki
Classification: Unclassified
Templates (Other open bugs)
unspecified
All All
: Normal enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
http://en.wikipedia.org/wiki/Template...
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2007-10-15 16:35 UTC by Stewart Gordon
Modified: 2010-02-10 15:11 UTC (History)
1 user (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Stewart Gordon 2007-10-15 16:35:55 UTC
A number of templates on Wikipedia, such as those for placing boilerplate messages on user talk pages, are intended to be substituted.  However, doing so creates a bit of markup bloat because of the conditional stuff in them.  In other words, inserting e.g.
    {{subst:uw-test1}}

on a page copies not only the text that actually appears on the page, but also the {{#if:...}} stuff that is in the template code.

The current workaround is to use
    {{subst:uw-test1|subst:subst=}}

However, it seems likely that very few people (remember to) do this every time.  It would therefore be good to have a keyword that defers substitution of a template within a template until the outer template is substituted.

I propose that subst1 be used for this purpose.  Let Template:Outer contain {{subst1:Inner}}.

When viewing Template:Outer, this would display the contents of Template:Inner, just as if {{Inner}} had been used by itself.  However, when {{subst:Outer}} is later entered on another page, the substitution process would automagically change {{subst1:Inner}} to {{subst:Inner}}, which is then immediately replaced by the contents of Template:Inner.

This would enable templates that use the |subst:subst= idiom to shrink slightly, from
    {{{{{subst|}}}#if:{{{2|}}}|{{{2}}}|Thank you.}}
to
    {{subst1:#if:{{{2|}}}|{{{2}}}|Thank you.}}

and at the same time stop people having to (forget to) add |subst:subst= to reduce the amount of markup code generated by these message templates.
Comment 1 Stewart Gordon 2007-11-30 14:14:03 UTC
I don't know if it would be worth implementing higher levels of deferred substition - subst2 would become subst1 when substed, and so on....
Comment 2 Stewart Gordon 2008-03-10 01:54:21 UTC
Oops ... I've just realised I typed "subst:subst=" a few times when I meant "subst=subst:".  This brings out another problem with this idiom: it's prone to mistyping; this is another good reason to implement this feature to supersede it. -- ~~~~
Comment 3 Conrad Irwin 2010-02-10 14:36:25 UTC
Since safesubst: was added in r61710. You will be able to use:

{{<includeonly>safesubst:</includeonly>#if:{{{2|}}}|{{{2}}}|Thank you.}},

or if you want slightly shorter syntax:

{{ {{{|safesubst:}}}#if:{{{2|}}}|{{{2}}}|Thank you. }}

The user of the template can use {{subst:uw-test1}} like normal, and {{safesubst:uw-test1}} would also work.

See http://en.wikipedia.org/wiki/Help:Substitution#safesubst: for more information.
Comment 4 Stewart Gordon 2010-02-10 15:05:13 UTC
Then this isn't WFM - it's a duplicate.  (Well, technically, that's a duplicate of this, but now that r61710 has been filed against bug 22297....)

The help page states that it doesn't yet work.  Does this mean that the feature has been folded into the codebase, but WP hasn't yet been updated to the latest version?

*** This bug has been marked as a duplicate of bug 22297 ***
Comment 5 Conrad Irwin 2010-02-10 15:11:24 UTC
(In reply to comment #4)
> Then this isn't WFM - it's a duplicate.  (Well, technically, that's a duplicate
> of this, but now that r61710 has been filed against bug 22297....)
> 
I closed it as WFM because the implementated solution does not act quite like the solution proposed here.

> The help page states that it doesn't yet work.  Does this mean that the feature
> has been folded into the codebase, but WP hasn't yet been updated to the latest
> version?
> 

Yes.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links