Difference between revisions of "Template:CheckElement"

From blackwiki
Jump to navigation Jump to search
imported>SkyLined
(Attempt to fix spaces problem #2)
imported>SkyLined
(Attempt to fix spaces problem #3)
Line 1: Line 1:
 
<includeonly>{{#switch:{{lc:{{{1}}} }}
 
<includeonly>{{#switch:{{lc:{{{1}}} }}
 
   |x|element={{#ifeq:{{lc:{{{link|}}} }} |yes
 
   |x|element={{#ifeq:{{lc:{{{link|}}} }} |yes
     |[[Category:Pages with incorrect nuclide templates use]]<!--
+
     |[[Category:Pages with incorrect nuclide templates use]]{{FormattingError
      -->{{FormattingError
+
       |The generic element '{{{1}}}' does not have a page to link to.|nocategory={{{nocategory|}}}
       |The generic element '{{{1}}}' does not have a page to link to.
 
      |nocategory={{{nocategory|}}}
 
 
     }}<!--
 
     }}<!--
 
   -->}}
 
   -->}}
Line 17: Line 15:
 
       |sulphur=sulfur
 
       |sulphur=sulfur
 
       |cesium=caesium
 
       |cesium=caesium
     }}.
+
     }}.|nocategory={{{nocategory|}}}<!--
    |nocategory={{{nocategory|}}}<!--
 
  
 
   -->}}
 
   -->}}
Line 145: Line 142:
  
 
     -->{{FormattingError
 
     -->{{FormattingError
     |unknown element {{{1}}}.
+
     |unknown element {{{1}}}.|nocategory={{{nocategory|}}}
    |nocategory={{{nocategory|}}}
 
 
   }}<!--
 
   }}<!--
 
-->}}</includeonly><noinclude>
 
-->}}</includeonly><noinclude>

Revision as of 20:21, 20 September 2009

Template documentation[view] [edit] [history] [purge]

Template that returns an error message if the first argument is not valid for use with other nuclide templates helper templates.

Usage

When using a string that is not a valid element name or symbol or "x" or "element", an error message is returned, like so:

  • {{CheckElement|C}} will return ""
  • {{CheckElement|Carbon}} will return ""
  • {{CheckElement|Blablabla}} will return "unknown element Blablabla."

The "link=yes" argument is also supported; if the element name or symbol has no associated link, an error message is returned, like so:

  • {{CheckElement|link=yes|C}} will return ""
  • {{CheckElement|link=yes|Carbon}} will return ""
  • {{CheckElement|link=yes|X}} will return "The generic element 'X' does not have a page to link to."

When using a common name for an element that goes against the Wikipedia style guide for element names, a warning message will be returned. There are currently three such names:

  • {{CheckElement|Aluminum}} will return "Aluminum is not a validway to spell aluminium."
  • {{CheckElement|Sulphur}} will return "Sulphur is not a validway to spell sulfur."
  • {{CheckElement|Cesium}} will return "Cesium is not a validway to spell caesium."

This template can be used in other templates to check for error before calling other templates that require a valid element or symbol like so:

{{#if:{{CheckElement|{{{element argument}}}|link={{{link|}}} }}
 | Error message (shown when the element is invalid).
 | Normal message (shown when the element is valid).
}}

See also

Template:Periodic table templates