Difference between revisions of "Template:AnA"

From Encyclopedia of Scientonomy
Jump to navigation Jump to search
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 
<noinclude>
 
<noinclude>
This template is used to add an indefinite article - <code><nowiki>an</nowiki></code> or <code><nowiki>a</nowiki></code> to the word. The template checks the first character of the string and does the following:
+
The template is used to return the indefinite article - <code><nowiki>an</nowiki></code> or <code><nowiki>a</nowiki></code> for the given word. The template checks the first character of the string and does the following:
* for a, e, i, o, u, it adds an "an"
+
* for a, e, i, o, u, it returns an "an"
* for other letters, adds an "a"
+
* for other letters, returns an "a"
* for anything else, returns the original string
 
  
 
'''NOTE:''' As any "printing" template, it doesn't store any values anywhere, but merely returns a value.
 
'''NOTE:''' As any "printing" template, it doesn't store any values anywhere, but merely returns a value.
Line 13: Line 12:
 
-->{{#if: {{{1|}}}<!--
 
-->{{#if: {{{1|}}}<!--
 
  -->|<!--
 
  -->|<!--
   -->{{#switch: {{#sub:{{{1}}}|0|1}}<!--
+
   -->{{#switch: {{lc:{{#sub:{{{1}}}|0|1}}}}<!--
 
   -->|a<!--
 
   -->|a<!--
 
   -->|e<!--
 
   -->|e<!--
 
   -->|i<!--
 
   -->|i<!--
 
   -->|o<!--
 
   -->|o<!--
   -->|u=an {{{1}}}<!--
+
   -->|u=an<!--
 
   -->|b<!--
 
   -->|b<!--
 
   -->|c<!--
 
   -->|c<!--
Line 39: Line 38:
 
   -->|x<!--
 
   -->|x<!--
 
   -->|y<!--
 
   -->|y<!--
   -->|z=a {{{1}}}<!--
+
   -->|z=a<!--
   -->|{{{1}}}<!-- if not a letter return the string
+
   -->|<!-- if not a letter, nothing to return
 
   -->}}<!-- switch
 
   -->}}<!-- switch
 
-->}}<!-- if
 
-->}}<!-- if
 
--><!--
 
--><!--
 
--></includeonly>
 
--></includeonly>

Latest revision as of 23:00, 9 January 2023

The template is used to return the indefinite article - an or a for the given word. The template checks the first character of the string and does the following:

  • for a, e, i, o, u, it returns an "an"
  • for other letters, returns an "a"

NOTE: As any "printing" template, it doesn't store any values anywhere, but merely returns a value.

Parameters:

  • string - any string to which the article should be added.