Template:TvC-ColorsBeta: Difference between revisions

Template page
(Created page with "<!-- Template: ColorMultiWord --> {{#vardefine: sentence | {{{1}}} }} <!-- Store the original sentence --> <!-- Loop through each additional argument dynamically --> {{#forargs: | index | arg | <!-- If color is defined for this index --> {{#if: {{{color|}}} | <!-- Apply color based on the index argument (dynamic word-color pairs) --> {{#switch: {{{color|}}} | red = {{#vardefine: sentence | {{#replace: {{#var: sentence}} | {{{word}}} | <span style="co...")
 
No edit summary
 
Line 1: Line 1:
<!-- Template: ColorMultiWord -->
<!-- TvC-Colors template -->
{{#vardefine: sentence | {{{1}}} }} <!-- Store the original sentence -->
{{#define: color | {{{color}}} }}
{{#define: word | {{{word}}} }}


<!-- Loop through each additional argument dynamically -->
<span style="color:{{#switch: {{{color}}}  
{{#forargs: | index | arg |
  | red = #FF6347
  <!-- If color is defined for this index -->
  | blue = #87CEEB
  {{#if: {{{color|}}} |
  | yellow = #FFD700
    <!-- Apply color based on the index argument (dynamic word-color pairs) -->
  | green = #90EE90
    {{#switch: {{{color|}}}
  | #default = inherit
      | red = {{#vardefine: sentence | {{#replace: {{#var: sentence}} | {{{word}}} | <span style="color:#FF6347;">{{{word}}}</span> }}}}}
}}">{{{word}}}</span>
      | blue = {{#vardefine: sentence | {{#replace: {{#var: sentence}} | {{{word}}} | <span style="color:#87CEEB;">{{{word}}}</span> }}}}}
      | yellow = {{#vardefine: sentence | {{#replace: {{#var: sentence}} | {{{word}}} | <span style="color:#FFD700;">{{{word}}}</span> }}}}}
      | green = {{#vardefine: sentence | {{#replace: {{#var: sentence}} | {{{word}}} | <span style="color:#90EE90;">{{{word}}}</span> }}}}}
    }}
  }}
}}
 
<!-- Output the final sentence with the replacements -->
{{#var: sentence}}

Latest revision as of 13:25, 11 September 2024

{{#define: color | {{{color}}} }} {{#define: word | {{{word}}} }}

{{{word}}}