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

           Summary: New transclusion classes
           Product: MediaWiki extensions
           Version: any
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: Normal
         Component: Extensions requests
        AssignedTo: [email protected]
        ReportedBy: [email protected]


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


-- 
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
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to