Difference between revisions of "Template:NextRoman"

From Pathfinder Wiki
Line 1: Line 1:
 
<noinclude>
 
<noinclude>
 
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.
 
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. 
  
 
*<nowiki>{{</nowiki>NextRoman|AY Honors/Camp Craft}} -> {{NextRoman|AY Honors/Camp Craft}}
 
*<nowiki>{{</nowiki>NextRoman|AY Honors/Camp Craft}} -> {{NextRoman|AY Honors/Camp Craft}}
Line 10: Line 12:
 
*<nowiki>{{</nowiki>NextRoman|AY Honors/Bully Prevention I}} -> {{NextRoman|AY Honors/Bully Prevention I}}
 
*<nowiki>{{</nowiki>NextRoman|AY Honors/Bully Prevention I}} -> {{NextRoman|AY Honors/Bully Prevention I}}
 
*<nowiki>{{</nowiki>NextRoman|AY Honors/Bully Prevention II}} -> {{NextRoman|AY Honors/Bully Prevention II}}
 
*<nowiki>{{</nowiki>NextRoman|AY Honors/Bully Prevention II}} -> {{NextRoman|AY Honors/Bully Prevention II}}
 +
*<nowiki>{{</nowiki>NextRoman|AY Honors/Insects}} -> {{NextRoman|AY Honors/Insects}}
 +
*<nowiki>{{</nowiki>NextRoman|AY Honors/Abseiling - Instructor}} -> {{NextRoman|AY Honors/Abseiling - 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 <nowiki>[[</nowiki>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 <nowiki>{{#explode:{{#var:landing}}| |-1}}</nowiki>.  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''" with the return value from Proxima (plus a leading space).  I thought the leading space is important to gaurd against replacing just any capital I in the honorname with II, but maybe I was overthinking that.  In cases where Proxima returned the same thing as it was passed, the replacement function does nothing, since it's replacing something with itself.
  
 
</noinclude>{{#vardefine:landing|{{#titleparts:{{{1}}}|2}}}}{{#vardefine:lastword|{{#explode:{{#var:landing}}| |-1}}}}{{#vardefine:nextroman|{{#replace:{{#var:landing}}| {{#var:lastword}}| {{Proxima|{{#var:lastword}}}}}}}}{{#ifexist:{{#ifeq:{{#var:landing}}|{{#var:nextroman}}||{{#var:nextroman}}}}|[[{{#var:nextroman}}{{GetLangSuffix|page={{{1}}}}}|{{GetHonorName|page={{{1}}}}}]]}}
 
</noinclude>{{#vardefine:landing|{{#titleparts:{{{1}}}|2}}}}{{#vardefine:lastword|{{#explode:{{#var:landing}}| |-1}}}}{{#vardefine:nextroman|{{#replace:{{#var:landing}}| {{#var:lastword}}| {{Proxima|{{#var:lastword}}}}}}}}{{#ifexist:{{#ifeq:{{#var:landing}}|{{#var:nextroman}}||{{#var:nextroman}}}}|[[{{#var:nextroman}}{{GetLangSuffix|page={{{1}}}}}|{{GetHonorName|page={{{1}}}}}]]}}

Revision as of 05:08, 4 February 2021

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}} ->
  • {{NextRoman|AY Honors/Camping Skills I}} -> Camping Skills I
  • {{NextRoman|AY Honors/Camping Skills II}} -> Camping Skills II
  • {{NextRoman|AY Honors/Camping Skills III}} -> Camping Skills III
  • {{NextRoman|AY Honors/Camping Skills III/es}} -> Camping Skills III
  • {{NextRoman|AY Honors/Camping Skills IV}} ->
  • {{NextRoman|AY Honors/Bully Prevention I}} -> Bully Prevention I
  • {{NextRoman|AY Honors/Bully Prevention II}} ->
  • {{NextRoman|AY Honors/Insects}} ->
  • {{NextRoman|AY Honors/Abseiling - 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" with the return value from Proxima (plus a leading space). I thought the leading space is important to gaurd against replacing just any capital I in the honorname with II, but maybe I was overthinking that. In cases where Proxima returned the same thing as it was passed, the replacement function does nothing, since it's replacing something with itself.