Template:Code: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(Revamp: use {{{preset}}} for style presets instead of {{{style}}}; {{{style}}} now specifies CSS like other templates; use <syntaxhighlight> instead of <code> for parity with wp:Template:Code; add alias {{{background}}} for {{{bg}}}) |
||
Line 1: | Line 1: | ||
<onlyinclude><includeonly><!-- CHOMP | |||
< | -->{{ #tag: syntaxhighlight | ||
| {{{ code | {{{ 1 | }}} }}} <!-- CHOMP | |||
-->| style = user-select: {{ #switch: {{{ select | <!-- NOP --> }}} <!-- this should probably be word-only since adding integrals means an ugly switch-case --> | |||
| 1 = all | |||
| 2 = none | |||
| #default = {{{ select | inherit }}} | |||
}}< | }};<!-- CHOMP | ||
-->{{ #switch: | |||
{{ #iferror: | |||
{{ #expr: trunc({{{ style | {{{ preset }}} }}}) = {{{ style | {{{ preset }}} }}} and | |||
1 <= {{{ style | {{{ preset | NO }}} }}} and | |||
{{{ style | {{{ preset | STOP }}} }}} <= 4 }} <!-- CHOMP | |||
// `style` is CSS styles --> | |||
| {{ #if: {{{ preset | <!-- NOP --> }}} | |||
| USE_PRESET <!-- CHOMP // `preset` specified; override `style` | |||
-->| STYLE_WITH_CSS <!-- CHOMP // use `style` like every other template does it | |||
-->}} <!-- CHOMP | |||
// `style` or `preset` is numbered preset; known real number in interval [1, 4] --> | |||
| DEPRECATED_STYLE_AS_PRESET<!-- CHOMP | |||
-->}}<!-- END #IFERROR | |||
-->| USE_PRESET <!-- | |||
-->| DEPRECATED_STYLE_AS_PRESET = {{ #ifexpr: {{{ style | {{{ preset }}} }}} = 3 | |||
| color: {{ #if: {{{ color | <!-- NOP --> }}} | {{{ color }}} | currentcolor }};<!-- CHOMP | |||
-->background-color: inherit; | |||
| background-color: {{ #ifexpr: {{{ style | {{{ preset }}} }}} <= 2 | |||
| rgb(0 0 0 / 16%) | |||
| rgb(255 255 255 / 5%) | |||
}};<!-- CHOMP | |||
-->border: {{ #ifexpr: {{{ style | {{{ preset }}} }}} != 2 | |||
| 1px solid rgb(255 255 255 / 10%) | |||
| none | |||
}}; | |||
}} | |||
| STYLE_WITH_CSS = background-color: {{ #if: {{{ background | <!-- NOP --> }}}{{{ bg | <!-- NOP --> }}} | {{{ background | {{{ bg }}} }}} | rgb(0 0 0 / 35%) }};<!-- CHOMP | |||
-->border: 1px solid rgb(255 255 255 / 15%);<!-- CHOMP | |||
-->color: {{ #if: {{{ color | <!-- NOP --> }}} | {{{ color }}} | inherit }};<!-- CHOMP | |||
-->{{{ style | <!-- NOP --> }}} | |||
| #default = all: inherit; <!-- Unreachable codepath unless you bork something up there | |||
-->}}<!-- CHOMP, END #IF | |||
-->| lang = {{{ lang | text }}} | |||
| class = {{{ class | }}} | |||
| id = {{{ id | }}} | |||
| inline = 1 | |||
}}</includeonly></onlyinclude> | |||
<noinclude>{{Doc}}</noinclude> |
Revision as of 08:10, 29 April 2023
The above documentation is transcluded from Template:Code/doc. (Edit | Page history)
Editors can experiment in this template's sandbox (create | mirror) and testcases (create) pages.
Editors can experiment in this template's sandbox (create | mirror) and testcases (create) pages.