Difference between revisions of "Template:PrevRoman"

From Pathfinder Wiki
(Copy from NextRoman)
 
 
(One intermediate revision by the same user not shown)
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 previous 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 previous honor in the series does not exist, it will return nothing.
  
 
This template should not be translated.  It should work for any language.
 
This template should not be translated.  It should work for any language.
 
==Examples==
 
==Examples==
  
*<nowiki>{{</nowiki>NextRoman|AY Honors/Camp Craft}} -> {{NextRoman|AY Honors/Camp Craft}}  
+
*<nowiki>{{</nowiki>PrevRoman|AY Honors/Camp Craft}} -> {{PrevRoman|AY Honors/Camp Craft}}  
 
:No roman numeral in the honor name.
 
:No roman numeral in the honor name.
*<nowiki>{{</nowiki>NextRoman|AY Honors/Camping Skills I}} -> {{NextRoman|AY Honors/Camping Skills I}}
+
*<nowiki>{{</nowiki>PrevRoman|AY Honors/Camping Skills I}} -> {{PrevRoman|AY Honors/Camping Skills I}}
*<nowiki>{{</nowiki>NextRoman|AY Honors/Camping Skills II}} -> {{NextRoman|AY Honors/Camping Skills II}}
+
*<nowiki>{{</nowiki>PrevRoman|AY Honors/Camping Skills II}} -> {{PrevRoman|AY Honors/Camping Skills II}}
*<nowiki>{{</nowiki>NextRoman|AY Honors/Camping Skills III}} -> {{NextRoman|AY Honors/Camping Skills III}}
+
*<nowiki>{{</nowiki>PrevRoman|AY Honors/Camping Skills III}} -> {{PrevRoman|AY Honors/Camping Skills III}}
*<nowiki>{{</nowiki>NextRoman|AY Honors/Camping Skills III/es}} -> {{NextRoman|AY Honors/Camping Skills III/es}}
+
*<nowiki>{{</nowiki>PrevRoman|AY Honors/Camping Skills III/es}} -> {{PrevRoman|AY Honors/Camping Skills III/es}}
 
:It works in Spanish!
 
:It works in Spanish!
*<nowiki>{{</nowiki>NextRoman|AY Honors/Camping Skills IV}} -> {{NextRoman|AY Honors/Camping Skills IV}}  
+
*<nowiki>{{</nowiki>PrevRoman|AY Honors/Camping Skills IV}} -> {{PrevRoman|AY Honors/Camping Skills IV}}  
:There is no Camping Skills V.
+
*<nowiki>{{</nowiki>PrevRoman|AY Honors/Bully Prevention I}} -> {{PrevRoman|AY Honors/Bully Prevention I}}
*<nowiki>{{</nowiki>NextRoman|AY Honors/Bully Prevention I}} -> {{NextRoman|AY Honors/Bully Prevention I}}
+
*<nowiki>{{</nowiki>PrevRoman|AY Honors/Bully Prevention II}} -> {{PrevRoman|AY Honors/Bully Prevention II}}
*<nowiki>{{</nowiki>NextRoman|AY Honors/Bully Prevention II}} -> {{NextRoman|AY Honors/Bully Prevention II}}
 
:No Bully Prevention III honor.
 
*<nowiki>{{</nowiki>NextRoman|AY Honors/Insects}} -> {{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.
 
*<nowiki>{{</nowiki>NextRoman|AY Honors/Abseiling - Instructor}} -> {{NextRoman|AY Honors/Abseiling - Instructor}}
 
:Instructor starts with a Roman numeral, but doesn't end that way.  Proxima returns "Instructor".
 
  
 
==Mechanics==
 
==Mechanics==
The template starts by defining three variables:
+
See [[:Template:NextRoman]] for an explanation of the mechanics
;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'' 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]].
+
</noinclude>{{#vardefine:landing|{{#titleparts:{{{1}}}|2}}}}{{#vardefine:lastword|{{#explode:{{#var:landing}}| |-1}}}}{{#vardefine:prevroman|{{#replace:{{#var:landing}}|{{#var:lastword}}|{{Prior|{{#var:lastword}}}}}}{{GetLangSuffix|page={{{1}}}}}}}{{#ifexist:{{#ifeq:{{#var:landing}}{{GetLangSuffix|page={{{1}}}}}|{{#var:prevroman}}||{{#var:prevroman}}}}|[[{{#var:prevroman}}|{{GetHonorName|page={{#var:prevroman}}}}]]}}
 
 
</noinclude>{{#vardefine:landing|{{#titleparts:{{{1}}}|2}}}}{{#vardefine:lastword|{{#explode:{{#var:landing}}| |-1}}}}{{#vardefine:nextroman|{{#replace:{{#var:landing}}|{{#var:lastword}}|{{Proxima|{{#var:lastword}}}}}}{{GetLangSuffix|page={{{1}}}}}}}{{#ifexist:{{#ifeq:{{#var:landing}}|{{#var:nextroman}}||{{#var:nextroman}}}}|[[{{#var:nextroman}}|{{GetHonorName|page={{#var:nextroman}}}}]]}}
 

Latest revision as of 21:18, 26 June 2021

If the link to the honor in {{{1}}} is an honor that ends with a roman numeral, and the previous 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 previous honor in the series does not exist, it will return nothing.

This template should not be translated. It should work for any language.

Examples

  • {{PrevRoman|AY Honors/Camp Craft}} ->
No roman numeral in the honor name.
It works in Spanish!

Mechanics

See Template:NextRoman for an explanation of the mechanics