Template:Hidden multi-line

From Sarkarverse
Jump to navigation Jump to search
Documentation icon Template documentation[view] [edit] [history] [purge]
abcdefgh
88
77
66
55
44
33
22
11
abcdefgh

This is a "wrapper" for Template:Hidden and provides the following additional facilities:

  • Long or right-aligned captions do not overlap the "show"/"hide" link.
  • The header text can be multi-line, and automatically increases its height as needed.
  • Separate background colours for the header text and "show"/"hide" link.
  • Options to control the font-size of the header text, content text and "show"/"hide" link.
  • Options to control the line-spacing and font-weight of the header text and content text.
  • Options to provide additional CSS for the header text, content text and "show"/"hide" link if you want more detailed control of their appearance.

In the example on the right, {{Hidden multi-line}} is used within the caption area of {{Chess diagram}}. Sorry about the lurid colours, the example tries to show as many options in use as possible - all the default colours are "transparent".

If you want to enhance this template or produce a special-purpose version of it:

  • see Help:Template for technical guidance.
  • do not change the default values of parameters, as this may break existing uses of the template.

Usage

Example - caption and content un-named
{{Hidden multi-line | Botvinnik-Yudovich,<br />USSR Championship 1933
| After [[sacrifice (chess) | sacrificing]] a piece to expose Black's King, Botvinnik played 1. Bh5+ and Yudovich resigned as mate is inevitable, e.g. 1. ... Kxh5; 2. Ng3+ followed by 3. Qe4+ Rf4; 4. Qxf4#.
| caption-bg=cyan | showhide-bg=yellow | content-bg=lime }}
Example - caption and content parameters are named
{{Hidden multi-line | caption-bg=cyan | showhide-bg=yellow | content-bg=lime }}
| content-text=After [[sacrifice (chess) | sacrificing]] a piece to expose Black's King, Botvinnik played 1. Bh5+ and Yudovich resigned as mate is inevitable, e.g. 1. ... Kxh5; 2. Ng3+ followed by 3. Qe4+ Rf4; 4. Qxf4#.
| caption-text=Botvinnik-Yudovich,<br />USSR Championship 1933}}

Required parameters

caption-text
Text for the caption. If unnamed, this must be the 1st parameter.
This template has been tested with plain text, with HTML codes that generate special characters and with wiki-links. It has not been tested with text containing HTML tags. In particular, attempts to use HTML tags that are not allowed within the HTML <P> tag (paragraph) may break the layout.
If you want to split the caption text into multiple lines, as in the example, insert the HTML tag <br /> in the right place (including the < and >).
The simple syntax for external web links, [http://www.anyoldsite.com Some page at that site], does not work in the caption-text - in fact it makes the caption-text invisible! This appears to be a limitation of Template:Hidden, which this template uses. However the "cite web" template is OK, provided you are prepared to handle complaints about there being no "accessdate" parameter ("accessdate" would add the text "Retrieved on ...", which you would not want in the caption). You can even include a <br /> tag in the title, as the example shows.
content-text
Text for the hidden content that is revealed when the user clicks "show". If unnamed, this must be the 2nd parameter.
Most HTML tags should work here if correctly coded. If they do not, there may be a fault in {{Hidden}}, as {{Hidden multi-line}} simply passes the content text to {{Hidden}}.

Optional parameters

These have defaults that work in the context for which {{Hidden multi-line}} was originally designed (chess diagrams):

Name Default value Allowed values Function & notes
showhide-size 120% Any valid CSS font-size. % sizes are probably the easiest. Size of the "show"/"hide" link.
Note: If you change this, you will also have to change caption-size because of the way the box model works.
showhide-width 4em Any valid CSS width. em is probably the easiest unit to use here. how much space to allow for the "show"/"hide" link.
caption-align center left
center
right
Alignment of the caption.
caption-size 90% Any valid CSS font-size. % sizes are probably the easiest. Size of the caption / header text.
caption-spacing 110% Any valid CSS height. % sizes are probably the easiest. Line-spacing in the caption.
caption-weight normal normal
bold
Whether the caption is in bold or normal font.
caption-bg transparent Any valid CSS colour. Background colour of the caption. Note: in this case "transparent" means "use the background colour of the show/hide section", because of the way the box model works.
caption-css (nothing) Any valid CSS code. Note: if there is a conflict between caption-css and any of the other caption formatting parameters, caption-css will override the others.
content-align left left
center
right
Alignment of the content when revealed.
content-bg transparent Any valid CSS colour. Background colour of the content when revealed. Note: in this case "transparent" really means transparent, i.e. same background colour as the setting in which this template is used.

General notes

  1. It seems impossible to make the "show"/"hide" link bold.

See also