Template:RarityWithArticle: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
m (update to also support when a value of "common" is explicitly provided) |
||
(2 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
<includeonly>{{#switch:{{{1}}} | <includeonly>{{#if:{{{1|}}}| | ||
{{#switch:{{{1}}} | |||
| common = a common | |||
| uncommon = an uncommon | | uncommon = an uncommon | ||
| rare = a rare | | rare = a rare | ||
| very rare = a very rare | | very rare = a very rare | ||
| legendary = a legendary | | legendary = a legendary | ||
| a common | | story = a quest-related | ||
}}</includeonly><noinclude> | | an (unknown rarity) | ||
}} | |||
|a common}}</includeonly><noinclude> | |||
This is useful for auto-generating text with a template, in which you'd like to refer to an item's rarity in the flow of a sentence, like so: | This is useful for auto-generating text with a template, in which you'd like to refer to an item's rarity in the flow of a sentence, like so: | ||
{{code|<nowiki>The {{{name}}} is {{RarityWithArticle|{{{rarity}}}}} item.</nowiki>}} | {{code|<nowiki>The {{{name}}} is {{RarityWithArticle|{{{rarity}}}}} item.</nowiki>}} | ||
Suppose the 'name' is "Worgfang" and the 'rarity' is "uncommon". Then the result would be: | Suppose the 'name' is "Worgfang" and the 'rarity' is "uncommon". Then the result would be: | ||
The Worgfang is {{RarityWithArticle|uncommon}} item. | |||
For an empty rarity value, it will say "a common": | |||
The Dagger is {{RarityWithArticle|}} item. | |||
For an invalid / unrecognized rarity value, it will say "an (unknown rarity)": | |||
The Weird Sword is {{RarityWithArticle|what's this}} item. | |||
</noinclude> | </noinclude> |
Latest revision as of 19:46, 28 February 2023
This is useful for auto-generating text with a template, in which you'd like to refer to an item's rarity in the flow of a sentence, like so:
The {{{name}}} is {{RarityWithArticle|{{{rarity}}}}} item.
Suppose the 'name' is "Worgfang" and the 'rarity' is "uncommon". Then the result would be:
The Worgfang is an uncommon item.
For an empty rarity value, it will say "a common":
The Dagger is a common item.
For an invalid / unrecognized rarity value, it will say "an (unknown rarity)":
The Weird Sword is an (unknown rarity) item.