Last modified: 2011-04-14 15:14:36 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 T20939, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 18939 - New transclusion classes
New transclusion classes
Status: NEW
Product: MediaWiki extensions
Classification: Unclassified
Extensions requests (Other open bugs)
unspecified
All All
: Low enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-05-26 19:09 UTC by BlindWanderer
Modified: 2011-04-14 15:14 UTC (History)
0 users

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


Attachments

Description BlindWanderer 2009-05-26 19:09:06 UTC
Currently there is only one class of transclusion, lets call it "Template" it is modulated with the tags "noinclude" "includeonly" and "onlyinclude". This is adequate in most cases but not all, especially where articles are built with the Extension:VariablesExtension.

So to solve this problem I propose some new tags:

<render class=""></render>
<renderonly class=""></renderonly>
<norender class=""></norender>
<onlyrender inner="" outer=""></onlyrender>

The class attribute takes after the CSS class attribute and is a space separated list.
You put your transclusion inside a "render" tag, and that causes the other tags to either include or not include their content based on shared class. "inner" and "outer" are both class attributes, outer is used to specify how to treat the parent's other content.

Now the tricky design decision is if it should integrate with "Template" or sit along side. The easy solution is to have it sit along side.

----
Integration: (a lot of work)

If it were to integrate with "Template" you would need to add two new classes: lets give them the constants "#include" and "#base"

* default article class="#base"
* default transclusion class="#include"
* <includeonly> => <renderonly class="#include">
* <noinclude> => <renderonly class="#base">
* <onlyinclude> => <onlyrender inner="#include" outer="#base">

As you can see this will requires substantial rewiring of MediaWiki, I doubt it can be done easily.

----
Along Side: (easy)

Implementing this to run along side is easy and can even be done as templates (if you have ParserFunctions, ArrayExtension and VariableExtension installed). The syntax is a little different but that is because the problem is slightly different.

Four templates:
* {{render|class=*|data=*}}
* {{renderonly|class=*|data=*}}
* {{renderbut|class=*|data=*}}
* {{norender|data=*}}

You will notice the logic is wrapped in if's, that's so whitespace can be included.

==={{render|class=*|data=*}}===

{{#if:
	{{#arraydefine:rendering~|{{{class|}}}|/\s+/}}
	{{#if:{{#var:rendering}}|
		{{#vardefine:rendering|1}}
		{{#arraymerge:rendering~1|rendering~}}
	|
		{{#vardefine:rendering-last|{{#var:rendering}}}}
		{{#vardefine:rendering|{{#expr:{{#var:rendering}} + 1}}}}
		{{# arrayintersect:rendering~{{#var:rendering}}|rendering~|rendering~{{#var:rendering-last}}}}
	}}
	{{#arrayreset:rendering~}}
}}{{{data|}}}{{#if:.
	{{#arrayreset:rendering~{{#var:rendering}}}}
	{{#vardefine:rendering|{{#ifexpr:{{#var:rendering}} > 1|{{#expr:{{#var:rendering}} - 1}}}}}}
}}

==={{renderonly|class=*|data=*}}===

{{#if:{{#var:rendering}}|{{#if:
	{{#arraydefine:renderonly-a|{{{class|}}}|/\s+/}}
	{{#arrayintersect:renderonly-b|renderonly-a|rendering~{{#var:rendering}}}}
}}{{#ifexpr:{{#arraysize:renderonly-b}} > 0|{{{data|}}}}}{{#if:
	{{#arrayreset:renderonly-a,renderonly-b}}
}}}}

==={{renderbut|class=*|data=*}}===

{{#if:{{#var:rendering}}|{{#if:{{{class|}}}|{{#if:
	{{#arraydefine:renderonly-a|{{{class|}}}|/\s+/}}
	{{#arrayintersect:renderonly-b|renderonly-a|rendering~{{#var:rendering}}}}
}}{{#ifexpr:{{#arraysize:renderonly-b}}=0|{{{data|}}}}}{{#if:
	{{#arrayreset:renderonly-a,renderonly-b}}
}}|{{{data|}}}}}|{{{data|}}}}}

==={{norender|data=*}}===

{{#if:{{#var:rendering}}||{{{data|}}}}}

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


Navigation
Links