सामग्रीमा जानुहोस्

ढाँचा:Class mask/कागजात/custom

विकिपिडिया, एक स्वतन्त्र विश्वकोशबाट

This template subpage contains a mask which normalises the input passed to |class=. This can be thought of as the 'default' mask, but it is possible for banners to define their own individual masks with wider or fewer choices of acceptable inputs.

If the page corresponding to {{{BANNER_NAME}}}/class exists and QUALITY_SCALE=subpage is set in the banner, then control is passed to the code on that page to normalise the input, and no modification is performed by the WPBannerMeta itself. The following parameters are available to be used:

  • |class=
  • |b1= through |b6=

Some caveats:

Any alternative mask needs to be carefully designed to handle all inputs correctly, with care given to case-insentivity, etc.

The following code accepts only the standard 1.0 assessment scale with a few extras:

{{#switch:{{lc:{{{class|}}}}}
 |fa       = FA
 |fl       = FL
 |a        = A
 |ga       = GA
 |b        = B
 |c        = C
 |start    = Start
 |stub     = Stub
 |list     = List
 |template = Template
 |image    = Image
}}

This code imitates the MilHist scale: no C-Class and a B-Class checklist:

{{#switch:{{lc:{{{class|}}}}}
 |fa   = FA
 |fl   = FL
 |a    = A
 |ga   = GA
 |b={{#ifexpr:
      {{#switch:{{lc:{{{b1|}}}}}|y|yes|1=1|0}}*
      {{#switch:{{lc:{{{b2|}}}}}|y|yes|1=1|0}}*
      {{#switch:{{lc:{{{b3|}}}}}|y|yes|1=1|0}}*
      {{#switch:{{lc:{{{b4|}}}}}|y|yes|1=1|0}}*
      {{#switch:{{lc:{{{b5|}}}}}|y|yes|1=1|0}}
     |B
     |Start
    }}
 |start= Start
 |stub = Stub
}}

This code imitates the WPMaths scale, which also incorporates a "B+" class:

{{#switch:{{lc:{{{class|}}}}}
 |fa       = FA
 |fl       = FL
 |a        = A
 |ga       = GA
 |bplus|b+ = Bplus
 |b        = B
 |start    = Start
 |stub     = Stub
 |list     = List
}}

An example with Merge, Needed, Future & Current classes:

{{#switch: {{lc:{{{class}}}}}
 |fa   = FA
 |fl   = FL
 |a    = A
 |ga   = GA
 |b    = B
 |c    = C
 |start= Start
 |stub = Stub
 |list = List
 |na                  = NA
 |image|file          = Image
 |category|cat|categ  = Category
 |disambig|disamb|dab = Disambig
 |portal              = Portal
 |redirect|red|redir  = Redirect
 |template|temp|templ = Template
 |project             = Project
 |current             = Current
 |future              = Future
 |needed              = Needed
 |merge               = Merge
 |#default={{#switch:{{lc:{{NAMESPACE}}}}
  |file talk      = Image
  |category talk  = Category
  |portal talk    = Portal
  |template talk  = Template
  |wikipedia talk = Project
 }}
}}

A minor problem with the examples above is that someone clicking the link from the banner template to see the custom mask will be presented with a blank page (you have to edit the page to see there's actually code). A simple solution is to add a local wrapper to your code, replacing the basic structure:

{{#switch: {{lc:{{{class}}}}}

...

}}

with this one:

<noinclude>:''[[Template:WPBannerMeta#Custom masks|Custom mask]]
used by {{tl|{{BASEPAGENAME}}}}:''
<pre></noinclude>{{#switch: {{lc:{{{class}}}}}

...

}}<noinclude></pre></noinclude>

For a visual example, you can go to Template:WikiProject Academic Journals and click the "custom class" link in the warning box: instead of a blank page you will be presented with Template:WikiProject Academic Journals/class that explains what it is and shows the full code of the mask. (Do not pay attention to the "noinclude" showing up around the code, it's a local side-effect of the Pre tag that doesn't affect the banner or the mask at all once transcluded.)