Template:NextRoman

From Pathfinder Wiki
Revision as of 05:24, 4 February 2021 by Jomegat (talk | contribs)

If the link to the honor in {{{1}}} is an honor that ends with a roman numeral, and the next honor in the series exists, this template will return a link to that honor. If the honor doesn't end with a roman numeral, or if the next honor in the series does not exist, it will return nothing.

Note that the existence check is only done on the English version of the honor. If the translation does not exist, this will produce a link to a page that does not yet exist.

  • {{NextRoman|AY Honors/Camp Craft}} ->
No roman numeral in the honor name.
It works in Spanish!
  • {{NextRoman|AY Honors/Camping Skills IV}} ->
There is no Camping Skills V.
  • {{NextRoman|AY Honors/Bully Prevention I}} -> Bully Prevention II
  • {{NextRoman|AY Honors/Bully Prevention II}} ->
No Bully Prevention III honor.
  • {{NextRoman|AY Honors/Insects}} ->
Insects starts with a Roman numeral, but it does not stand alone as a Roman numeral. Also, the last word (as per #explode) would be Honors/Insects since it ignores slashes and just looks at spaces to divide words.
  • {{NextRoman|AY Honors/Abseiling - Instructor}} ->
Instructor starts with a Roman numeral, but doesn't end that way. Proxima returns "Instructor".

Mechanics

The template starts by defining three variables:

landing
page title of the honor's landing page. We are assuming here that the landing page is located at [[AY Honors/honor]] (though "AY Honor" could be anything. The point is, that landing truncates the page so that it's only dealing with the first two elements of the page title.
lastword
is the last word in the honor's page title, where each word is delimited by a space. This is done with the {{#explode:{{#var:landing}}| |-1}}. The space before the -1 parameter is the delimiter.
nextroman
This is the name of the next honor in the series. It is constructed by passing lastword to Template:Proxima (Proxima is Latin for next because I was feeling clever) which returns the next Roman numeral (up to X). If its parameter is not a Roman numeral it returns the parameter unmodified. With the output of Proxima in hand, the markup then replaces lastword in landing with the return value from Proxima. In cases where Proxima returned the same thing as it was passed, the replacement function does nothing, since it's replacing something with itself.

Once these three variables are defined, we can check to see if a page named nextroman exists. If it does, we return a wikilink to that page - adjusted for the language suffix of {{{1}}}. The displayname is retrieved by passing {{{1}}}' to Template:GetHonorName.