Last modified: 2011-04-14 15:10:28 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 T24636, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 22636 - Make current variables available for transcluded templates.
Make current variables available for transcluded templates.
Status: NEW
Product: MediaWiki
Classification: Unclassified
Parser (Other open bugs)
unspecified
All All
: Low enhancement with 2 votes (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-02-24 17:44 UTC by René Kijewski
Modified: 2011-04-14 15:10 UTC (History)
5 users (show)

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


Attachments

Description René Kijewski 2010-02-24 17:44:22 UTC
It would be nice, if there would be a easier way to access the variables the "parent" template has received.

Example:
* Template {{A}} transcludes one out of three templates (let’s call them {{A/n}}), depending on a parameter it was "called" with.
* Overall, {{A/n}} are all the same, save some minor differences like their background color or the order of the lines in the infobox they are part of.
* Thus {{A/n}} have to get the same parameters. And especially they have to get the same parameters as {{A}} was "called" with. Only the one distinguishing parameter may not be needed.

By now, {{A}} would be something like
{{switch:{{{1}}}
|a={{A/1|par0={{{par0}}}|..|parM={{{parM}}}}}
|b={{A/2|par0={{{par0}}}|..|parM={{{parM}}}}}
|c={{A/3|par0={{{par0}}}|..|parM={{{parM}}}}}
}}.
There is much needless overhead in the source code, which could be rather good evaded, if {{A/n}} would be aware of {{A}}’s parameters, making {{A}}’s code:
{{switch:{{{1}}} |a={{A/1}} |b={{A/2}} |c={{A/3}} }}.

Proposal:
There would be three options, how to make {{A/n}} aware of {{A}}’s parameters:
* Always give the own parameters to transcluded templates.
* Add a new parameter accessing prefix for {{A/n}}: {{{..:par0}}}.
* Transclude {{A/n}} differently: {{include:A/1}}.

I would prefer the third option, because it would likely 1) be the easiest to implement, 2) have least overhead and 3) be the most explicit variant.

Main beneficiaries would be beasts like [[Template:Location map]].
Comment 1 Fabian 2010-02-24 18:34:36 UTC
Hello René, how do you want to implement the third option with {{include:A/1}}? To send the parameters of {{A}} to the transcluded template {{A/1}} and {{A/1}} can access for example to {{{par0}}} of {{A}} easily by write {{{par0}}}.
Comment 2 Bart 2010-02-24 18:45:12 UTC
http://en.wikipedia.org/wiki/Template:Infobox_Weather/concise_F takes parameters and passes them to http://en.wikipedia.org/wiki/Template:Infobox_Weather

|location = {{{location|}}}
In here, the concise_F template takes a possible location parameter (if present) and passes it to the location parameter which is part of the called (parent) Infobox_Weather template.
Comment 3 Happy-melon 2010-02-26 00:05:53 UTC
Essentially, any parameters which are not explicitly overridden should be passed through:

[[Page]]:
----
{{outerTemplate|1=foo|2=bar}}
--------

[[Template:OuterTemplate]]:
----
{{innerTemplate|2=quok|4=nada}}
--------

[[Template:InnerTemplate]]:
----
1: {{{1}}}, 2: {{{2}}}, 3: {{{3}}}, 4: {{{4}}}
--------


Should output 
----
1: foo, 2: quok, 3: {{{3}}}, 4: nada
--------

Whether to enable that parameter fallthrough by default, or only in specific cases, is another question.
Comment 4 Fabian 2010-02-26 08:20:31 UTC
But there you maybe have side effects, when some inner templates uses the same parametername as the outer template. Because when the inner template is not designed to be the inner template and some parameters with the same name but not the same usage will be overridden. I would suggest, to add prefixes to determine the „namespace“. For example {{{i:<name>}}} if you do not want to override it (default) or {{{o:<name>}}} if you only want to use the outer parameter or {{{c:<name>}}} to implement your way.
Is this the suggestion with the {{{include:…}}} from René?
Comment 5 René Kijewski 2010-02-26 12:47:18 UTC
(In reply to comment #4)
> ...
> Is this the suggestion with the {{{include:…}}} from René?

Yes, exactly.
Comment 6 Fabian 2010-02-26 13:14:07 UTC
But what does happen when you input {{include:…}} ? Do you send your parameters to the parameters of the inner template?
Comment 7 René Kijewski 2010-02-26 14:50:13 UTC
(In reply to comment #6)
> But what does happen when you input {{include:…}} ? Do you send your parameters
> to the parameters of the inner template?

Sorry, I did not understand your question. Could you make an example?
Did you mean whether your parameters should be transcluded to _all_ inner templates? I'd say no.
Comment 8 Fabian 2010-02-26 18:20:55 UTC
Okay… I have two templates. One template generate a tablecontainer and one template for each row (e.g. the Template table and row). In the table you could switch some columns on/off and you set the rows which should know the visible columns. My idea is, that the row can ask the table for the visible columns. But the question how the row can get the information.

For example the table template shows always an id and a name column. Optionally you could show a country column.
At the moment every row need a parameter for „showcountry“:
{{table | showcountry = yes | content = {{row|id=0|name=Hello World|country=Vulcan}}{{row|id=1|name=42|showcountry=yes}}}}
In the second row you can't leave country blank (column will be invisible) or you have to set, that there is a country column. But when the template row can ask the template table if there is a country column you could save one parameter.

But my problem is: What will the include-option do? And where do you want to place this option?
Comment 9 René Kijewski 2010-02-27 04:10:05 UTC
(In reply to comment #8)

I thought {{include:...}} as a kind of shortcut for having to include every parameter explicitly.
I would be nice, if the inner child could ask some outer template for its parameters, too.

Both would fulfill the same interest. I have no strong opinion, which option should be implemented (maybe both?). I'd leave it to the developers to tell, which would be easier to implement or have less overhead.
Comment 10 Fabian 2010-02-27 09:48:04 UTC
Can you give me an example of the implementation of yout include suggestion? For me the {{....}} are confusing, because this would be a template implementation and we want to add a feature to the parameters actually.
Comment 11 Fabian 2010-07-09 18:08:25 UTC
Okay, what is the status of this feature?

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


Navigation
Links