Пређи на садржај

Шаблон:Font color

Iz Vojne Enciklopedije

{{ safesubst:#if:

| {{ safesubst:#if: 
     | {{ safesubst:#ifeq:  | yes
     | [[ {{ safesubst:#if:1|  }}|{{ safesubst:#if:1|  }}]]
     | [[|{{ safesubst:#if:1|  }}]]
     }}
   | {{ safesubst:#if:1|  }}
   }}
| {{ safesubst:#if: 
     | {{ safesubst:#ifeq:  | yes
     | [[ {{ safesubst:#if:1|  }} |{{ safesubst:#if:1|  }}]]
     | [[ {{ safesubst:#if:1|  }} |{{ safesubst:#if:1|  }}]]
   }}
 | {{ safesubst:#if:1|  }}
 }}

}}

Документација шаблона[прикажи] [уреди] [историја] [освежи]

{{#ifeq:font color |док

    | 

{{#ifeq:show |show

|
        }}{{#if: |
         |   {{#ifexist:Шаблон:Font color
                  | [[Категорија:Документација {{#switch:Шаблон |Шаблон=шаблона |Модул=модула |Корисник=корисничких страница |#default=Википедије}}]]
                  | 
                 }}
        }}
    | 
   }}

Purpose

{{ Font color }} is how you insert colorized text, such as {{ safesubst:#if:

| {{ safesubst:#if: 
     | {{ safesubst:#ifeq:  | yes
     | [[ {{ safesubst:#if:1|  }}|{{ safesubst:#if:1|  }}]]
     | [[|{{ safesubst:#if:1|  }}]]
     }}
   | {{ safesubst:#if:1|  }}
   }}
| {{ safesubst:#if: 
     | {{ safesubst:#ifeq:  | yes
     | [[ {{ safesubst:#if:1|  red  }} |{{ safesubst:#if:1|  red  }}]]
     | [[ {{ safesubst:#if:1|  }} |{{ safesubst:#if:1|  red  }}]]
   }}
 | {{ safesubst:#if:1|  red  }}
 }}

}}, {{ safesubst:#if:

| {{ safesubst:#if: 
     | {{ safesubst:#ifeq:  | yes
     | [[ {{ safesubst:#if:1|  }}|{{ safesubst:#if:1|  }}]]
     | [[|{{ safesubst:#if:1|  }}]]
     }}
   | {{ safesubst:#if:1|  }}
   }}
| {{ safesubst:#if: 
     | {{ safesubst:#ifeq:  | yes
     | [[ {{ safesubst:#if:1|  orange  }} |{{ safesubst:#if:1|  orange  }}]]
     | [[ {{ safesubst:#if:1|  }} |{{ safesubst:#if:1|  orange  }}]]
   }}
 | {{ safesubst:#if:1|  orange  }}
 }}

}}, {{ safesubst:#if:

| {{ safesubst:#if: 
     | {{ safesubst:#ifeq:  | yes
     | [[ {{ safesubst:#if:1|  }}|{{ safesubst:#if:1|  }}]]
     | [[|{{ safesubst:#if:1|  }}]]
     }}
   | {{ safesubst:#if:1|  }}
   }}
| {{ safesubst:#if: 
     | {{ safesubst:#ifeq:  | yes
     | [[ {{ safesubst:#if:1|  green  }} |{{ safesubst:#if:1|  green  }}]]
     | [[ {{ safesubst:#if:1|  }} |{{ safesubst:#if:1|  green  }}]]
   }}
 | {{ safesubst:#if:1|  green  }}
 }}

}}, {{ safesubst:#if:

| {{ safesubst:#if: cat
     | {{ safesubst:#ifeq: cat | yes
     | [[ {{ safesubst:#if:1|  }}|{{ safesubst:#if:1|  }}]]
     | {{ safesubst:#if:1|  }}
     }}
   | {{ safesubst:#if:1|  }}
   }}
| {{ safesubst:#if: cat
     | {{ safesubst:#ifeq: cat | yes
     | [[ {{ safesubst:#if:1|  blue  }} |{{ safesubst:#if:1|  blue  }}]]
     | [[ {{ safesubst:#if:1| cat }} |{{ safesubst:#if:1|  blue  }}]]
   }}
 | {{ safesubst:#if:1|  blue  }}
 }}

}} and {{ safesubst:#if:

| {{ safesubst:#if: 
     | {{ safesubst:#ifeq:  | yes
     | [[ {{ safesubst:#if:1|  }}|{{ safesubst:#if:1|  }}]]
     | [[|{{ safesubst:#if:1|  }}]]
     }}
   | {{ safesubst:#if:1|  }}
   }}
| {{ safesubst:#if: 
     | {{ safesubst:#ifeq:  | yes
     | [[ {{ safesubst:#if:1|  indigo  }} |{{ safesubst:#if:1|  indigo  }}]]
     | [[ {{ safesubst:#if:1|  }} |{{ safesubst:#if:1|  indigo  }}]]
   }}
 | {{ safesubst:#if:1|  indigo  }}
 }}

}}, and many others. You can specify its {{ safesubst:#if: background

| {{ safesubst:#if: 
     | {{ safesubst:#ifeq:  | yes
     | [[ {{ safesubst:#if:1| background }}|{{ safesubst:#if:1| background }}]]
     | [[|{{ safesubst:#if:1| background }}]]
     }}
   | {{ safesubst:#if:1| background }}
   }}
| {{ safesubst:#if: 
     | {{ safesubst:#ifeq:  | yes
     | [[ {{ safesubst:#if:1| yellow }} |{{ safesubst:#if:1| yellow }}]]
     | [[ {{ safesubst:#if:1|  }} |{{ safesubst:#if:1| yellow }}]]
   }}
 | {{ safesubst:#if:1| yellow }}
 }}

}} color at the same time.

{{ Font color }} is also how you can color wikilinks to something other than blue for when you need to work within background colors. Normally [[ wikilink ]]wikilink, but but here we use a {{ font color }} with |{{SAFESUBST:#if: link | link =}} to create a black wikilink → {{ safesubst:#if:    wikilink   

| {{ safesubst:#if: yes
     | {{ safesubst:#ifeq: yes | yes
     | [[ {{ safesubst:#if:1|     wikilink     }}|{{ safesubst:#if:1|     wikilink     }}]]
     | {{ safesubst:#if:1|     wikilink     }}
     }}
   | {{ safesubst:#if:1|     wikilink     }}
   }}
| {{ safesubst:#if: yes
     | {{ safesubst:#ifeq: yes | yes
     | [[ {{ safesubst:#if:1|  violet  }} |{{ safesubst:#if:1|  violet  }}]]
     | [[ {{ safesubst:#if:1| yes }} |{{ safesubst:#if:1|  violet  }}]]
   }}
 | {{ safesubst:#if:1|  violet  }}
 }}

}} You can make any text link to any page using the |{{SAFESUBST:#if:link|link=}} parameter.

This template will use the latest Wikipedia:HTML5 recommendations, inserting the span tags {{#switch:pair

|c|close  = 
|s|single
|o|open
|p|pair   = <span{{#if:style=color:color| style=color:color}}

}}{{#switch:pair

|c|close  = 
|s|single =  />
|o|open   = >
|p|pair   = >...

}}{{#switch:pair

|s|single
|o|open   = 
|c|close
|p|pair   = </span>

}} and {{#switch:pair

|c|close  = 
|s|single
|o|open
|p|pair   = <span{{#if:style=background-color:color| style=background-color:color}}

}}{{#switch:pair

|c|close  = 
|s|single =  />
|o|open   = >
|p|pair   = >...

}}{{#switch:pair

|s|single
|o|open   = 
|c|close
|p|pair   = </span>

}} for you, so your page increases its readability and usability in both the wikitext and the rendered page.

Usage

{{{{#if: Font color | Font color | tlf|...}}{{#ifeq:x|| |{{{2}}} | }}{{#ifeq:x|| |{{{3}}} | }}{{#ifeq:x|| |{{{4}}} | }}{{#ifeq:x|| |{{{5}}} | }}{{#ifeq:x|| |{{{6}}} | }}{{#ifeq:x|| |{{{7}}} | }}{{#ifeq:x|| |{{{8}}} | }}{{#ifeq:x|| |{{{9}}} | }}}} has a one-color and a two-color form:

{{font color | color | text }}
{{font color | text color | background color | text }}.

Either form has a |link= option, for colorizing (otherwise blue or red) wikilink text.

|link=yes[[text]]
|link=fullpagename[[fullpagename]]

You can also name the other fields.

{{font color | fg=color | text=text }}
{{font color | fg=text color | bg=background color | text=text }}

You can name |fg= or |bg=, which is nice, but... if you name either of them, you must also name |text=, which is a compromise. (See Help:Template#Parameters for why.)

Spacing is of no concern.

.{{font color|tan|green|text with four words}}..{{ safesubst:#if: text with four words
| {{ safesubst:#if: 
     | {{ safesubst:#ifeq:  | yes
     | [[ {{ safesubst:#if:1| text with four words  }}|{{ safesubst:#if:1| text with four words  }}]]
     | [[|{{ safesubst:#if:1| text with four words  }}]]
     }}
   | {{ safesubst:#if:1| text with four words  }}
   }}
| {{ safesubst:#if: 
     | {{ safesubst:#ifeq:  | yes
     | [[ {{ safesubst:#if:1| green }} |{{ safesubst:#if:1| green }}]]
     | [[ {{ safesubst:#if:1|  }} |{{ safesubst:#if:1| green }}]]
   }}
 | {{ safesubst:#if:1| green }}
 }}

}}.

. {{font color|tan|green|text with four words}} .. {{ safesubst:#if: text with four words
| {{ safesubst:#if: 
     | {{ safesubst:#ifeq:  | yes
     | [[ {{ safesubst:#if:1| text with four words  }}|{{ safesubst:#if:1| text with four words  }}]]
     | [[|{{ safesubst:#if:1| text with four words  }}]]
     }}
   | {{ safesubst:#if:1| text with four words  }}
   }}
| {{ safesubst:#if: 
     | {{ safesubst:#ifeq:  | yes
     | [[ {{ safesubst:#if:1| green }} |{{ safesubst:#if:1| green }}]]
     | [[ {{ safesubst:#if:1|  }} |{{ safesubst:#if:1| green }}]]
   }}
 | {{ safesubst:#if:1| green }}
 }}

}} .

. {{ font color | tan | green | text with four words }} .. {{ safesubst:#if: text with four words
| {{ safesubst:#if: 
     | {{ safesubst:#ifeq:  | yes
     | [[ {{ safesubst:#if:1|   text    with    four     words  }}|{{ safesubst:#if:1|   text    with    four     words  }}]]
     | [[|{{ safesubst:#if:1|   text    with    four     words  }}]]
     }}
   | {{ safesubst:#if:1|   text    with    four     words  }}
   }}
| {{ safesubst:#if: 
     | {{ safesubst:#ifeq:  | yes
     | [[ {{ safesubst:#if:1|   green   }} |{{ safesubst:#if:1|   green   }}]]
     | [[ {{ safesubst:#if:1|  }} |{{ safesubst:#if:1|   green   }}]]
   }}
 | {{ safesubst:#if:1|   green   }}
 }}

}} .

Parameters

Use / description Default value
{{{1}}} text color inherited
{{{2}}} text
link =yes or =fullpagename
Or
Use / description Default value
{{{1}}} text color inherited
{{{2}}} background color inherited
{{{3}}} text
link =yes or =fullpagename

Examples

Markup Renders as
{{ font color | green | green text }} {{ safesubst:#if: {{ safesubst:#if: yes [[ {{ safesubst:#if:1| }}|{{ safesubst:#if:1| }}]] [[|{{ safesubst:#if:1| }}]]
     }}
}}
   }}
{{ safesubst:#if: yes [[ {{ safesubst:#if:1| green text }} |{{ safesubst:#if:1| green text }}]] [[ {{ safesubst:#if:1| }} |{{ safesubst:#if:1| green text }}]]
   }}
green text }}
 }}

}}

{{ font color | blue | do not style text as a link }} {{ safesubst:#if: {{ safesubst:#if: yes [[ {{ safesubst:#if:1| }}|{{ safesubst:#if:1| }}]] [[|{{ safesubst:#if:1| }}]]
     }}
}}
   }}
{{ safesubst:#if: yes [[ {{ safesubst:#if:1| do not style text as a link }} |{{ safesubst:#if:1| do not style text as a link }}]] [[ {{ safesubst:#if:1| }} |{{ safesubst:#if:1| do not style text as a link }}]]
   }}
do not style text as a link }}
 }}

}}

{{ font color | white | black | white with black background }} {{ safesubst:#if: white with black background {{ safesubst:#if: yes [[ {{ safesubst:#if:1| white with black background }}|{{ safesubst:#if:1| white with black background }}]] [[|{{ safesubst:#if:1| white with black background }}]]
     }}
white with black background }}
   }}
{{ safesubst:#if: yes [[ {{ safesubst:#if:1| black }} |{{ safesubst:#if:1| black }}]] [[ {{ safesubst:#if:1| }} |{{ safesubst:#if:1| black }}]]
   }}
black }}
 }}

}}

{{ font color || yellow | default text in yellow background }} {{ safesubst:#if: default text in yellow background {{ safesubst:#if: yes [[ {{ safesubst:#if:1| default text in yellow background }}|{{ safesubst:#if:1| default text in yellow background }}]] [[|{{ safesubst:#if:1| default text in yellow background }}]]
     }}
default text in yellow background }}
   }}
{{ safesubst:#if: yes [[ {{ safesubst:#if:1| yellow }} |{{ safesubst:#if:1| yellow }}]] [[ {{ safesubst:#if:1| }} |{{ safesubst:#if:1| yellow }}]]
   }}
yellow }}
 }}

}}

{{ font color | bg=yellow | text = default text in yellow background }} {{ safesubst:#if: default text in yellow background {{ safesubst:#if: yes [[ {{ safesubst:#if:1| default text in yellow background }}|{{ safesubst:#if:1| default text in yellow background }}]] [[|{{ safesubst:#if:1| default text in yellow background }}]]
     }}
default text in yellow background }}
   }}
{{ safesubst:#if: yes [[ {{ safesubst:#if:1| yellow }} |{{ safesubst:#if:1| yellow }}]] [[ {{ safesubst:#if:1| }} |{{ safesubst:#if:1| yellow }}]]
   }}
yellow }}
 }}

}}

Markup Renders as
{{ font color | white | blue | Wikipedia:Example | link = yes }} {{ safesubst:#if: Wikipedia:Example {{ safesubst:#if: yes yes [[ {{ safesubst:#if:1| Wikipedia:Example }}|{{ safesubst:#if:1| Wikipedia:Example }}]] {{ safesubst:#if:1| Wikipedia:Example }}
     }}
Wikipedia:Example }}
   }}
{{ safesubst:#if: yes yes [[ {{ safesubst:#if:1| blue }} |{{ safesubst:#if:1| blue }}]] [[ {{ safesubst:#if:1| yes }} |{{ safesubst:#if:1| blue }}]]
   }}
blue }}
 }}

}}

{{ font color | white | blue | Wikipedia:Example | link = Wikipedia:Sandbox }} {{ safesubst:#if: Wikipedia:Example {{ safesubst:#if: Wikipedia:Sandbox yes [[ {{ safesubst:#if:1| Wikipedia:Example }}|{{ safesubst:#if:1| Wikipedia:Example }}]] {{ safesubst:#if:1| Wikipedia:Example }}
     }}
Wikipedia:Example }}
   }}
{{ safesubst:#if: Wikipedia:Sandbox yes [[ {{ safesubst:#if:1| blue }} |{{ safesubst:#if:1| blue }}]] [[ {{ safesubst:#if:1| Wikipedia:Sandbox }} |{{ safesubst:#if:1| blue }}]]
   }}
blue }}
 }}

}}

{{ font color | text = Wikipedia:Example | link = Wikipedia:Sandbox | bg = blue | fg = white }} {{ safesubst:#if: Wikipedia:Example {{ safesubst:#if: Wikipedia:Sandbox yes [[ {{ safesubst:#if:1| Wikipedia:Example }}|{{ safesubst:#if:1| Wikipedia:Example }}]] {{ safesubst:#if:1| Wikipedia:Example }}
     }}
Wikipedia:Example }}
   }}
{{ safesubst:#if: Wikipedia:Sandbox yes [[ {{ safesubst:#if:1| blue }} |{{ safesubst:#if:1| blue }}]] [[ {{ safesubst:#if:1| Wikipedia:Sandbox }} |{{ safesubst:#if:1| blue }}]]
   }}
blue }}
 }}

}}

The |{{SAFESUBST:#if:link|link=}} parameter is a good way to colorize wikilinks, and it is about as much typing as the pipe trick.

Although a wikilink accepts a font color (or other template or markup):

[[Wikipedia:Example|{{font color|white|blue|the Wikipedia:Example page}}]]
→ [[Wikipedia:Example | {{ safesubst:#if: the Wikipedia:Example page
| {{ safesubst:#if: 
     | {{ safesubst:#ifeq:  | yes
     | [[ {{ safesubst:#if:1|  the Wikipedia:Example page }}|{{ safesubst:#if:1|  the Wikipedia:Example page }}]]
     | [[|{{ safesubst:#if:1|  the Wikipedia:Example page }}]]
     }}
   | {{ safesubst:#if:1|  the Wikipedia:Example page }}
   }}
| {{ safesubst:#if: 
     | {{ safesubst:#ifeq:  | yes
     | [[ {{ safesubst:#if:1|  blue  }} |{{ safesubst:#if:1|  blue  }}]]
     | [[ {{ safesubst:#if:1|  }} |{{ safesubst:#if:1|  blue  }}]]
   }}
 | {{ safesubst:#if:1|  blue  }}
 }}

}}]] (a font-colored link), a font color does not accept a wikilink, it creates wikilinks itself with |{{SAFESUBST:#if:link|link=}}.

  •  Урађено{{safesubst:#if:|: {{{објашњење}}}}} {{ font color | green | violet | Wikipedia:Example | link=yes }} → {{ safesubst:#if: Wikipedia:Example
| {{ safesubst:#if: yes
     | {{ safesubst:#ifeq: yes | yes
     | [[ {{ safesubst:#if:1|  Wikipedia:Example  }}|{{ safesubst:#if:1|  Wikipedia:Example  }}]]
     | {{ safesubst:#if:1|  Wikipedia:Example  }}
     }}
   | {{ safesubst:#if:1|  Wikipedia:Example  }}
   }}
| {{ safesubst:#if: yes
     | {{ safesubst:#ifeq: yes | yes
     | [[ {{ safesubst:#if:1|  violet  }} |{{ safesubst:#if:1|  violet  }}]]
     | [[ {{ safesubst:#if:1| yes }} |{{ safesubst:#if:1|  violet  }}]]
   }}
 | {{ safesubst:#if:1|  violet  }}
 }}

}} (a |{{SAFESUBST:#if:link|link=}} {{ font color }})

  • НеН{{ font color | green | violet | the [[Wikipedia:Example]] page}} → {{ safesubst:#if: the Wikipedia:Example page
| {{ safesubst:#if: 
     | {{ safesubst:#ifeq:  | yes
     | [[ {{ safesubst:#if:1|  the Wikipedia:Example page  }}|{{ safesubst:#if:1|  the Wikipedia:Example page  }}]]
     | [[|{{ safesubst:#if:1|  the Wikipedia:Example page  }}]]
     }}
   | {{ safesubst:#if:1|  the Wikipedia:Example page  }}
   }}
| {{ safesubst:#if: 
     | {{ safesubst:#ifeq:  | yes
     | [[ {{ safesubst:#if:1|  violet  }} |{{ safesubst:#if:1|  violet  }}]]
     | [[ {{ safesubst:#if:1|  }} |{{ safesubst:#if:1|  violet  }}]]
   }}
 | {{ safesubst:#if:1|  violet  }}
 }}

}} (Text with [[wikilink brackets]] overrides the designated color)

  • НеН{{ font color | green | violet | [[Wikipedia:Exammple]] }} → {{ safesubst:#if: the Wikipedia:Exammple page
| {{ safesubst:#if: 
     | {{ safesubst:#ifeq:  | yes
     | [[ {{ safesubst:#if:1|  the Wikipedia:Exammple page  }}|{{ safesubst:#if:1|  the Wikipedia:Exammple page  }}]]
     | [[|{{ safesubst:#if:1|  the Wikipedia:Exammple page  }}]]
     }}
   | {{ safesubst:#if:1|  the Wikipedia:Exammple page  }}
   }}
| {{ safesubst:#if: 
     | {{ safesubst:#ifeq:  | yes
     | [[ {{ safesubst:#if:1|  violet  }} |{{ safesubst:#if:1|  violet  }}]]
     | [[ {{ safesubst:#if:1|  }} |{{ safesubst:#if:1|  violet  }}]]
   }}
 | {{ safesubst:#if:1|  violet  }}
 }}

}} (Text with [[wikilink brackets]] overrides the designated color) For more examples see /testcases. For actual mainspace template usage, here are search links for

  • (језик: словеначки){{#if:true
|}}.
|}} showing its use in articles whose title begins with the letter "F".

See also