Difference between revisions of "Template:Article"

From Abulafia Random Generator Wiki
Jump to navigation Jump to search
m (+category)
m (clarify)
 
(9 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<includeonly>{{#ifeq:{{lc:{{#sub:{{{1|}}}|0|3}}}}|uni|
+
<includeonly>{{lcfirst:{{#ifeq:{{lc:{{#sub:{{{1|}}}|0|3}}}}|uni|
 
   a {{{1}}}|
 
   a {{{1}}}|
 
   {{#ifeq:{{lc:{{#sub:{{{1|}}}|0|1}}}}|a|
 
   {{#ifeq:{{lc:{{#sub:{{{1|}}}|0|1}}}}|a|
Line 17: Line 17:
 
     }}
 
     }}
 
   }}
 
   }}
}}</includeonly><noinclude>
+
}}}}</includeonly><noinclude>
This function prepends '''{{Article|Indefinite Article}}''' before the phrase sent to it. The intelligence it follows is thus: If the string passed starts with “uni” ({{article|university}}, {{article|unicycle}}), it gets preceded by an “a”. If not, if it starts with a vowel, it gets preceded by an “an”. Otherwise, it must start with a consonant, so gets preceded by an “a”. This will catch most, but not all, situations since there are likely other phonetic combinations other than “uni” that start with a vowel, but yield a consonant sound that should be an “a”, that can be coded in as they are located.
+
This function prepends <b>{{Article|Indefinite Article}}</b> before a string (text phrase) sent to it. Its logic is thus:
  
== Usage ==
+
* If the string starts with “uni” ({{article|university}}, {{article|unicycle}}), it gets preceded by an “a”.
<tt><nowiki>{{Article|aardvark}}</nowiki></tt> in an article’s text yields “{{Article|aardvark}}” upon the render of the page. You can use this template in the flow of a SGTable output (which is its most useful state, when you don’t know what that generator’s text output will be), such as:
+
* If not, if it starts with a vowel, it gets preceded by an “an”.
 
+
* Otherwise, it must start with a consonant, so gets preceded by an “a”.
{{Purge}}:''<sgdisplay iterations="1">I went out walking and ran across '''{{Article|[Animal.fantasyLand]}}''', '''{{Article|[Animal.fantasyLand]}}''', '''{{Article|[Animal.fantasyLand]}}''', '''{{Article|[Animal.fantasyLand]}}''', '''{{Article|[Animal.fantasyLand]}}''', '''{{Article|[Animal.fantasyLand]}}''', and '''{{Article|[Animal.fantasyLand]}}'''.</sgdisplay>
 
 
 
The above list should show all vowel-first animal names with an “an” in front of them (reload the page if no vowel-first animals appeared).
 
  
The template “ia” (for “indefinite article”) is a shortcut to this template, and can be used as <tt><nowiki>{{ia|aardvark}}</nowiki></tt> interchangeably, if you prefer a shorter command.</noinclude>
+
Note that this yields “{{article|unicorn}}” but also “{{article|uninvited guest}}” – it’s not perfect – but if necessary various other exceptions can be coded in as they are located.
<includeonly>{{#ifeq:{{lc:{{#sub:{{{1|}}}|0|3}}}}|uni|
 
  a {{{1}}}|
 
  {{#ifeq:{{lc:{{#sub:{{{1|}}}|0|1}}}}|a|
 
    an {{{1}}}|
 
    {{#ifeq:{{lc:{{#sub:{{{1|}}}|0|1}}}}|e|
 
      an {{{1}}}|
 
      {{#ifeq:{{lc:{{#sub:{{{1|}}}|0|1}}}}|i|
 
        an {{{1}}}|
 
        {{#ifeq:{{lc:{{#sub:{{{1|}}}|0|1}}}}|o|
 
          an {{{1}}}|
 
          {{#ifeq:{{lc:{{#sub:{{{1|}}}|0|1}}}}|u|
 
            an {{{1}}}|
 
            a {{{1|}}}
 
          }}
 
        }}
 
      }}
 
    }}
 
  }}
 
}}</includeonly><noinclude>
 
This function prepends '''{{Article|Indefinite Article}}''' before the phrase sent to it. The intelligence it follows is thus: If the string passed starts with “uni” ({{article|university}}, {{article|unicycle}}), it gets preceded by an “a”. If not, if it starts with a vowel, it gets preceded by an “an”. Otherwise, it must start with a consonant, so gets preceded by an “a”. This will catch most, but not all, situations since there are likely other phonetic combinations other than “uni” that start with a vowel, but yield a consonant sound that should be an “a”, that can be coded in as they are located.
 
  
 
== Usage ==
 
== Usage ==
<tt><nowiki>{{Article|aardvark}}</nowiki></tt> in an article’s text yields “{{Article|aardvark}}” upon the render of the page. You can use this template in the flow of a SGTable output (which is its most useful state, when you don’t know what that generator’s text output will be), such as:
+
{{Purge}}<tt><nowiki>{{Article|aardvark}}</nowiki></tt> in an article’s text yields “{{Article|aardvark}}” upon the render of the page. You can use this template in the flow of a SGTable output (which is its most useful state, when you don’t know what that generator’s text output will be), such as:
  
{{Purge}}:''<sgdisplay iterations="1">I went out walking and ran across '''{{Article|[Animal.fantasyLand]}}''', '''{{Article|[Animal.fantasyLand]}}''', '''{{Article|[Animal.fantasyLand]}}''', '''{{Article|[Animal.fantasyLand]}}''', '''{{Article|[Animal.fantasyLand]}}''', '''{{Article|[Animal.fantasyLand]}}''', and '''{{Article|[Animal.fantasyLand]}}'''.</sgdisplay>
+
''<sgdisplay iterations="1">
 +
I went out walking and ran across <b>{{Article|[Animal.fantasyLand]}}, {{Article|[Animal.fantasyLand]}}, {{Article|[Animal.fantasyLand]}}, {{Article|[Animal.fantasyLand]}}, {{Article|[Animal.fantasyLand]}}, {{Article|[Animal.fantasyLand]}}, and {{Article|[Animal.fantasyLand]}}</b>.
 +
</sgdisplay>
  
 
The above list should show all vowel-first animal names with an “an” in front of them (reload the page if no vowel-first animals appeared).
 
The above list should show all vowel-first animal names with an “an” in front of them (reload the page if no vowel-first animals appeared).
  
The template “ia” (for “indefinite article”) is a shortcut to this template, and can be used as <tt><nowiki>{{ia|aardvark}}</nowiki></tt> interchangeably, if you prefer a shorter command.</noinclude>
+
The template “ia” (for “indefinite article”) is a shortcut to this template, and can be used as <tt><nowiki>{{ia|aardvark}}</nowiki></tt> interchangeably, if you prefer a shorter command.
<noinclude>[[Category:Templates]]</noinclude>
+
 
 +
[[Category:Templates]]</noinclude>

Latest revision as of 08:39, 20 October 2015

This function prepends a Indefinite Article before a string (text phrase) sent to it. Its logic is thus:

  • If the string starts with “uni” (a university, a unicycle), it gets preceded by an “a”.
  • If not, if it starts with a vowel, it gets preceded by an “an”.
  • Otherwise, it must start with a consonant, so gets preceded by an “a”.

Note that this yields “a unicorn” but also “a uninvited guest” – it’s not perfect – but if necessary various other exceptions can be coded in as they are located.

Usage

  Reload
Generator

{{Article|aardvark}} in an article’s text yields “a aardvark” upon the render of the page. You can use this template in the flow of a SGTable output (which is its most useful state, when you don’t know what that generator’s text output will be), such as:

<sgdisplay iterations="1"> I went out walking and ran across a [Animal.fantasyLand], a [Animal.fantasyLand], a [Animal.fantasyLand], a [Animal.fantasyLand], a [Animal.fantasyLand], a [Animal.fantasyLand], and a [Animal.fantasyLand]. </sgdisplay>

The above list should show all vowel-first animal names with an “an” in front of them (reload the page if no vowel-first animals appeared).

The template “ia” (for “indefinite article”) is a shortcut to this template, and can be used as {{ia|aardvark}} interchangeably, if you prefer a shorter command.