Page MenuHomePhabricator

New transclusion classes
Open, LowPublicFeature

Description

Author: Blindwanderer

Description:
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=*}}

		{{#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}}}}

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

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

{{norender|data=*}}

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


Version: unspecified
Severity: enhancement

Details

Reference
bz18939

Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 10:39 PM
bzimport set Reference to bz18939.
bzimport added a subscriber: Unknown Object (MLST).
Aklapper changed the subtype of this task from "Task" to "Feature Request".Feb 4 2022, 11:01 AM
Aklapper removed a subscriber: wikibugs-l-list.