Difference between revisions of "Template:NextRoman"
From Pathfinder Wiki
m (Jomegat moved page Template:NextRoman to Template:NextRoman: Better name) |
|||
(12 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | {{ | + | <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. | ||
+ | |||
+ | This template should not be translated. It should work for any language. | ||
+ | ==Examples== | ||
+ | |||
+ | *<nowiki>{{</nowiki>NextRoman|AY Honors/Camp Craft}} -> {{NextRoman|AY Honors/Camp Craft}} | ||
+ | :No roman numeral in the honor name. | ||
+ | *<nowiki>{{</nowiki>NextRoman|AY Honors/Hyrdroponics and Aquaponics/es}} -> {{NextRoman|AY Honors/Hyrdroponics and Aquaponics/es}} | ||
+ | :No roman numeral in the honor name (in Spanish). | ||
+ | *<nowiki>{{</nowiki>NextRoman|AY Honors/Camping Skills I}} -> {{NextRoman|AY Honors/Camping Skills I}} | ||
+ | *<nowiki>{{</nowiki>NextRoman|AY Honors/Camping Skills II}} -> {{NextRoman|AY Honors/Camping Skills II}} | ||
+ | *<nowiki>{{</nowiki>NextRoman|AY Honors/Camping Skills III}} -> {{NextRoman|AY Honors/Camping Skills III}} | ||
+ | *<nowiki>{{</nowiki>NextRoman|AY Honors/Camping Skills III/es}} -> {{NextRoman|AY Honors/Camping Skills III/es}} | ||
+ | :It works in Spanish! | ||
+ | *<nowiki>{{</nowiki>NextRoman|AY Honors/Camping Skills IV}} -> {{NextRoman|AY Honors/Camping Skills IV}} | ||
+ | :There is no Camping Skills V. | ||
+ | *<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}} | ||
+ | :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== | ||
+ | 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'' 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:nextroman|{{#replace:{{#var:landing}}|{{#var:lastword}}|{{Proxima|{{#var:lastword}}}}}}{{GetLangSuffix|page={{{1}}}}}}}{{#ifexist:{{#ifeq:{{#var:landing}}{{GetLangSuffix|page={{{1}}}}}|{{#var:nextroman}}||{{#var:nextroman}}}}|[[{{#var:nextroman}}|{{GetHonorName|page={{#var:nextroman}}}}]]}} |
Latest revision as of 21:08, 26 June 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.
This template should not be translated. It should work for any language.
Examples
- {{NextRoman|AY Honors/Camp Craft}} ->
- No roman numeral in the honor name.
- {{NextRoman|AY Honors/Hyrdroponics and Aquaponics/es}} ->
- No roman numeral in the honor name (in Spanish).
- {{NextRoman|AY Honors/Camping Skills I}} -> Camping Skills II
- {{NextRoman|AY Honors/Camping Skills II}} -> Camping Skills III
- {{NextRoman|AY Honors/Camping Skills III}} -> Camping Skills IV
- {{NextRoman|AY Honors/Camping Skills III/es}} -> Camping Skills IV
- 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.