Template:A or b/Documentation

From GodWiki
< Template:A or b
Revision as of 11:57, 3 November 2019 by Djonni (talk | contribs) (→‎User-friendly wrappers: Fix parameter not displaying in example.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

The {{a or b}} function implements logic to decide randomly but consistently on a word or phrase to use in text on the GodWiki. It is here for the use of any creator who wishes to allow the Great Random to decide what something in their text should be. The most common use case is to switch an article daily between being about a her or about a him.

It can be called directly, but is most likely to be called by one of the more user-friendly wrapper templates below. You are reading this documentation on {{A or b}}; tables and brief usage notes for the full set of wrapper templates follow. For complete documentation on the master {{a or b}} template, skip to § Complete Parameters.

User-friendly wrappers

These tables show the wrapper functions for various common uses.

Wrapper functions for pronouns
Pronoun Case Uppercase lowercase
Subject {{He or She}} {{he or she}}
Object {{Him or Her}} {{him or her}}
Possessive {{His or Hers}} {{his or hers}}
Adjective {{His or Her}} {{his or her}}
Wrapper functions for nouns
Uppercase lowercase
{{Hero or Heroine}} {{hero or heroine}}
{{Heroes or Heroines}} {{heroes or heroines}}
{{God or Goddess}}[T 1] {{god or goddess}}
{{Gods or Goddesses}}[T 1] {{gods or goddesses}}
Phrases with "and"
Template wikicode Example result Note
{{heroes and heroines}} heroines and heroes Both words lowercase
{{Heroes and Heroines}} Heroines and heroes First word uppercase (for the start of a sentence)
{{gods and goddesses}} goddesses and gods Both words lowercase
{{Gods and Goddesses}} Goddesses and gods First word uppercase (for the start of a sentence)
{{Gods and Goddesses|uppercase=yes}} Goddesses and Gods Both words uppercase
  1. 1.0 1.1 Note: This wrapper is set so that, if |or=1 is used, the second word will be capitalised. All other capitalised templates in this set will lowercase the second word.

Wrapper Parameters

All of the wrappers accept these parameters to modify their behavior. None are required for normal use.

|or = anything
Optional. Set to any value to have the template output both alternates conjoined by or (as in the template name), rather than selecting one or the other. The wikicode "Maybe {{he or she|or=y}} will get a surprise." results in "Maybe she or he will get a surprise." or "Maybe he or she will get a surprise."
|daily = no or |d = no
Optional. Set to disable the automatic switching of gender-focus each day (which is enabled by default). The gender of pronouns generated by this template will be fixed for the life of the article (except where |invert=yes is used, see next parameter). Accepts any common negative value: "n", "0", "false", etc.
|invert = anything or |i = anything
Optional. If set to any value, reverses the usual order of the result. If the male-focussed language is being selected for the page, you will get the female-focussed language with this option, and vice versa.
Use this to build sensible sentences. For example:
{{He or She}} held {{his or her|invert=yes}} hand in the moonlight.
will always result in one of:
  • "She held his hand in the moonlight."
  • "He held her hand in the moonlight."
|uppercase=yes or |uc=yes or |u=yes
Only in {{Gods and Goddesses}}, this will make the second word in the phrase (after "and") uppercase.

Complete Parameters

These parameters are accepted by {{a or b}}. The wrapper templates pre-define some of these parameters, and as a result are less flexible (but more convenient).

|a=option a or |1=option a
Required. This parameter contains the text to return if the template decides to choose option a. E.g. |a=him
|b=option b or |2=option b
Required. This parameter contains the text to return if the template decides to choose option b. E.g. |b=her
Optional. This parameter instructs the template to return both parts conjoined by or. As in, "she or he will get a surprise".
Optional. This parameter instructs the template to lowercase the first letter of the second term in an or conjunction. Use it only if giving the template uppercase Option A and Option B text, with |or=yes. As in, "She or he will get a surprise". Omit this if you explicitly want a capital letter in your second term, as in, "Goddesses or Gods are welcome in this guild!"
|daily=yes or no or |d=yes or no
Optional, defaults to yes. This parameter instructs the template to switch the options in the text each day. Note that, depending on when the page was last cached, you may not always see the change immediately (without purging or editing the page).
|invert=anything or |i=anything
Optional. This parameter reverses the usual order of the result. If option a is usually being selected for the page, you will get option b, and vice versa. Allows sensible construction of sentences like: {{He or She}} kissed {{him or her|i=1}}. ("She kissed him.")

Note that the text given to {{a or b}} doesn't have to be male or female gendered text. For example:

{{a or b|a=He|b=She}} passed {{a or b|a=her|b=him}} the {{a or b|a=salt|b=pepper}}.

will switch daily between one of these two sentences:

  • "She passed him the pepper."
  • "He passed her the salt."

Decision Logic

The template uses the page's {{PAGEID}} property to decide, plus {{CURRENTDAY}}. If the sum is odd, the option a is chosen; if it's even, option b. (The page you are reading this on has a {{PAGEID}} value of 12352, and the {{CURRENTDAY}} is 24.) If the |daily= parameter is set to no, the current day of the month (24) is not added before testing if it's odd or even, so the result will remain the same every day.

When creating a new page, before the page is saved the {{PAGEID}} is not set. In these cases, the template will use the {{CURRENTTIMESTAMP}} of the preview, so that it will be consistent within each preview, but may switch with each preview. If you must know with certainly what the final result will be, save and create the page, and the {{PAGEID}} value will be generated.