https://bugzilla.wikimedia.org/show_bug.cgi?id=24284

Van de Bugger <van.de.bug...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |van.de.bug...@gmail.com

--- Comment #6 from Van de Bugger <van.de.bug...@gmail.com> 2011-10-06 17:52:49 
UTC ---
Hi all,

I have implemented it (or something very similar). My implementation cannot
distinguish actual template from redirection and always returns actual name,
but to me it is not important because behaviour variations can be easily
introduced by a parameter, as Krinkle said.

However, I found 2 *real* use cases where {{{0}}} is very convenient. A short
introduction: I run MediaWiki site with Semantic MediaWiki (SMW) extension, so
using templates is a must. Moreover, templates often complex and big. A;so, for
namespace Template I enabled subpages.

1. Subtemplates.
----------------

In SMW it is rather common that page is generated by one template. For
manageability I like split it to subtemplates, or sections, so main template
body looks like a series of calls to subtemplates:

<!-- Template region -->
{{ Region/Territory }}
{{ Region/Population }}
{{ Region/Industry }}
...

With pseudo-parameter {{{0}}} it could be written as:

<!-- Template region -->
{{ {{{0}}}/Territory }}
{{ {{{0}}}/Population }}
{{ {{{0}}}/Industry }}
...

Benefits:
(a) I do not have type template name each time.
(b) If I rename template page, all the subpages are renamed automatically and I
should not edit template code. Without {{{0}}} I would have to edit template
code to replace old template name with new one.


2. Template "local" variables.
------------------------------

For optimization purposes, I save result of semantic request in a variable for
later use, e. g.:

{{ #vardefine: r | {{ #show: ...Page selection... | ...Printout... }} }}

And then use it few times:

{{ #var: r }} ... {{ #var: r }}

The problem is: scope of variable definition is an article, not template.
Variable `r' defined in one template is accessible in another template included
(transcluded) into the same article. One template may accidentally reset
variable which is in use by another template,  so names of variables should be
carefully chosen. Usually I use template name as a prefix for variable name. It
leads to hardly readable code, for example: {{ #var: Template:Region/Industry_r
}}. ("Template:Region/Industry" is not the longest template name in my wiki.)

Again, renaming a template requires fixing its code to replace old template
name to new one. {{{0}}} helps much. Template-specific variable looks like: {{
#var: {{{0}}}_r }}}. It is short and does not require maintenance when template
is renamed.

Conclusion: I vote for {{{0}}}, it is really helps.

Patch will be committed soon. It is very small and simple: 3 lines of code × 2
files.

-- 
Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
You are on the CC list for the bug.
_______________________________________________
Wikibugs-l mailing list
Wikibugs-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to