Difference between revisions of "Template:Colors expand"
(Created page with "<noinclude> ==Usage== Expands a string containing 1 to 5 one-letter color abbreviations into a comma-separated list of the colours as words. ==Example== The following shortha...") |
|||
Line 2: | Line 2: | ||
==Usage== | ==Usage== | ||
Expands a string containing 1 to 5 one-letter color abbreviations into a comma-separated list of the colours as words. | Expands a string containing 1 to 5 one-letter color abbreviations into a comma-separated list of the colours as words. | ||
+ | |||
+ | The optional second parameter is either "and" or "or", for using a list of color names in a sentence. | ||
==Example== | ==Example== | ||
Line 7: | Line 9: | ||
<pre><nowiki> | <pre><nowiki> | ||
{{Colors expand|UBR}} | {{Colors expand|UBR}} | ||
+ | |||
+ | {{Colors expand|WR|or}} | ||
</nowiki></pre> | </nowiki></pre> | ||
Line 12: | Line 16: | ||
{{Colors expand|UBR}} | {{Colors expand|UBR}} | ||
+ | |||
+ | {{Colors expand|WR|or}} | ||
</noinclude><includeonly><!-- | </noinclude><includeonly><!-- | ||
− | -->{{Color expand|{{#invoke:String|sub|{{{1}}}|1|1}}}}<!-- | + | -->{{#switch:{{#invoke:String|len|{{{1}}}}} |
− | -->{{# | + | | 1 = {{Color expand|{{#invoke:String|sub|{{{1}}}|1|1}}}} |
− | -->{{# | + | | 2 = {{Color expand|{{#invoke:String|sub|{{{1}}}|1|1}}}}<!-- |
− | -->{{# | + | -->{{#if:{{{2|}}}| {{{2}}} |, }}<!-- |
− | -->{{ | + | -->{{Color expand|{{#invoke:String|sub|{{{1}}}|2|2}}}} |
− | --></includeonly> | + | | 3 = {{Color expand|{{#invoke:String|sub|{{{1}}}|1|1}}}}, <!-- |
+ | -->{{Color expand|{{#invoke:String|sub|{{{1}}}|2|2}}}}, <!-- | ||
+ | -->{{#if:{{{2|}}}|{{{2}}} }}<!-- | ||
+ | -->{{Color expand|{{#invoke:String|sub|{{{1}}}|3|3}}}} | ||
+ | | 4 = {{Color expand|{{#invoke:String|sub|{{{1}}}|1|1}}}}, <!-- | ||
+ | -->{{Color expand|{{#invoke:String|sub|{{{1}}}|2|2}}}}, <!-- | ||
+ | -->{{Color expand|{{#invoke:String|sub|{{{1}}}|3|3}}}}, <!-- | ||
+ | -->{{#if:{{{2|}}}|{{{2}}} }}<!-- | ||
+ | -->{{Color expand|{{#invoke:String|sub|{{{1}}}|4|4}}}} | ||
+ | | 5 = {{Color expand|{{#invoke:String|sub|{{{1}}}|1|1}}}}, <!-- | ||
+ | -->{{Color expand|{{#invoke:String|sub|{{{1}}}|2|2}}}}, <!-- | ||
+ | -->{{Color expand|{{#invoke:String|sub|{{{1}}}|3|3}}}}, <!-- | ||
+ | -->{{Color expand|{{#invoke:String|sub|{{{1}}}|4|4}}}}, <!-- | ||
+ | -->{{#if:{{{2|}}}|{{{2}}} }}<!-- | ||
+ | -->{{Color expand|{{#invoke:String|sub|{{{1}}}|5|5}}}} | ||
+ | }}</includeonly> |
Latest revision as of 01:04, 22 February 2019
Usage
Expands a string containing 1 to 5 one-letter color abbreviations into a comma-separated list of the colours as words.
The optional second parameter is either "and" or "or", for using a list of color names in a sentence.
Example
The following shorthand:
{{Colors expand|UBR}} {{Colors expand|WR|or}}
Produces:
Blue, Black, Red
White or Red