Page MenuHomePhabricator

Allow nested <onlyinclude> and <includeonly>
Open, LowestPublic

Description

Currently it is not possible to nest <includeonly> or <onlyinclude>, with all tags being processed on the page they appear.

I would like to propose that these tags be permitted to be nested, as this would allow templates to add <includeonly>, <onlyinclude> and <noinclude> tags to pages that use those templates, with deeper nesting allowing these tags to be passed higher and higher up the calling chain. Currently this is not possible at all, not even passing the tags up one level only, so the example below cannot be done.

ChildTemplate:

This text will appear on all pages.

<includeonly>
    This text will only appear on pages using ChildTemplate.
    <noinclude>
        This category will only appear on templates using ChildTemplate,
        but not on any templates using those ones.
        
        [[Category:Templates directly using ChildTemplate]]
    </noinclude>
</includeonly>

MainTemplate:

This text will appear on any page using MainTemplate.

{{ChildTemplate}}

Article:

This is the article text.

{{MainTemplate}}

With the proposed change, the pages would appear as follows:

ChildTemplate:

This text will appear on all pages.

MainTemplate:

This text will appear on any page using MainTemplate.

This text will appear on all pages.

This text will only appear on pages using ChildTemplate.
<noinclude>
    This category will only appear on templates using ChildTemplate,
    but not on any templates using those ones.

    [[Category:Templates directly using ChildTemplate]]
</noinclude>

Article:

This is the article text.

This text will appear on any page using MainTemplate.

This text will appear on all pages.

This text will only appear on pages using ChildTemplate.

Here, MainTemplate has some content enclosed in <noinclude> tags, but these tags are not present in MainTemplate's wikitext - the tags come from a child template, which is currently impossible.

This change would not break any current functionality, as nesting these tags currently has no effect, so they are never nested.

Event Timeline

Malvineous raised the priority of this task from to Low.
Malvineous updated the task description. (Show Details)
Malvineous added a project: MediaWiki-Parser.
Malvineous subscribed.

I think that you'd quickly end up with very unwieldy templates if this functionality were usable directly from wikitext. Note that either https://gerrit.wikimedia.org/r/#/c/141052/ or https://gerrit.wikimedia.org/r/#/c/169983/ would allow you do to do what you want from Scribunto in a cleaner and easier to understand way.

Aklapper lowered the priority of this task from Low to Lowest.Feb 9 2015, 12:43 AM