Template:Expand/doc: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Now supports indent as usual. Thanks, Max!)
(Being able to be indented appears to come with the price that {{expand}} can't be used in the middle of a line. It feels that this should be the way and not some margin_left parameter.)
 
(6 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Documentation subpage}}
{{Doc/subpage}}
<!-- Please place categories where indicated at the bottom of this page.) -->
<!-- Please place categories where indicated at the bottom of this page.) -->
== Usage ==
== Usage ==
Wraps content in a box that can dynamically be expanded or collapsed.
{{important|Do not use this template in the middle of a line. Start a new line, which also allows you to indent it using colons.
<source lang=html style=margin:0>
Text {{Expand|margin_left=2em|Text}} Text <!-- breaks -->
Text
:{{Expand|Text}} <!-- good! -->
Text
</source>
}}


=== Parameters ===
=== Parameters ===
{{inline note|bold=0|name={{param|1}}|The content to expand or hide.}}
* {{param|1}} &ndash; The content to expand or hide.
{{inline note|bold=0|name={{param|float}}|Set to <code>left</code> or <code>right</code> if floating is desired.}}
* {{param|float}} &ndash; Set to <code>left</code> or <code>right</code> if floating is desired. Using this parameter is preferable to adding <code>style=float:right</code> because this also adjusts the title alignment appropriately, see the example below.
{{inline note|bold=0|name={{param|title}}|An optional title shown next to the expand button.}}
* {{param|title}} &ndash; An optional title shown next to the expand button.
{{inline note|bold=0|name={{param|noborder}}|If non-zero, use no border on the left. {{warning|It can become difficult to tell where the expanded text ends if the background colors are identical!}}}}
* {{param|titlestyle}} &ndash; Adds extra title style parameters.
{{inline note|bold=0|name={{param|color}}|The color of the left border and title, if used.}}
* {{param|noborder}} &ndash; If non-zero, use no surrounding border. {{warning|It can become difficult to tell where the expanded text ends if the background colors are identical! Use this only if you would end up with double borders for example.}}
{{inline note|bold=0|name={{param|startcollapsed}}|If set to 0, the content will initially be visible, otherwise collapsed. Default is 1.}}
* {{param|startcollapsed}} &ndash; If set to 0, the content will initially be visible, otherwise collapsed. Default is 1.
{{inline note|bold=0|name={{param|style}}|Override style parameters for the table that this template is based on.}}
* {{param|color}} &ndash; The color of the left border and title, if used.
* {{param|bgcolor|rgba(0,0,0,0.05)}} &ndash; The background color of the content. This defaults to <code>transparent</code> if {{param|noborder}} is not 0.
* {{param|margin_bottom|1em}} &ndash; The border on the bottom.
* {{param|margin_left|0}} &ndash; The border on the left.
* {{param|style}} &ndash; Adds style parameters for the table that this template is based on.


=== Examples ===
=== Examples ===
<code><nowiki>{{expand|{{:Main Page}}}}</nowiki></code> renders as follows.
<code><nowiki>{{expand|{{KV Breakable}}}}</nowiki></code> renders as follows.
{{expand|{{:Main Page}}}}
{{expand|{{KV Breakable}}}}




<code><nowiki>{{expand|{{:Main Page}}|noborder=1}}</nowiki></code> renders as follows.
<code><nowiki>{{expand|{{KV Breakable}}|noborder=1}}</nowiki></code> renders as follows.
{{expand|{{:Main Page}}|noborder=1}}
{{expand|{{KV Breakable}}|noborder=1}}





Latest revision as of 23:39, 17 January 2025

Edit-copy.png
This is a documentation subpage for Template:Expand.
Don't forget to purge the contents of the base page upon creating or editing this subpage.

Usage

Wraps content in a box that can dynamically be expanded or collapsed.

Icon-Important.pngImportant:Do not use this template in the middle of a line. Start a new line, which also allows you to indent it using colons.
Text {{Expand|margin_left=2em|Text}} Text <!-- breaks -->

Text
:{{Expand|Text}} <!-- good! -->
Text

Parameters

  • {{{1}}} – The content to expand or hide.
  • {{{float}}} – Set to left or right if floating is desired. Using this parameter is preferable to adding style=float:right because this also adjusts the title alignment appropriately, see the example below.
  • {{{title}}} – An optional title shown next to the expand button.
  • {{{titlestyle}}} – Adds extra title style parameters.
  • {{{noborder}}} – If non-zero, use no surrounding border.
    Warning.pngWarning:It can become difficult to tell where the expanded text ends if the background colors are identical! Use this only if you would end up with double borders for example.
  • {{{startcollapsed}}} – If set to 0, the content will initially be visible, otherwise collapsed. Default is 1.
  • {{{color}}} – The color of the left border and title, if used.
  • {{{bgcolor|rgba(0,0,0,0.05)}}} – The background color of the content. This defaults to transparent if {{{noborder}}} is not 0.
  • {{{margin_bottom|1em}}} – The border on the bottom.
  • {{{margin_left|0}}} – The border on the left.
  • {{{style}}} – Adds style parameters for the table that this template is based on.

Examples

{{expand|{{KV Breakable}}}} renders as follows.

Breakable (common):
Performance Mode (PerformanceMode) <choices>
Used to limit the amount of gibs produced when this entity breaks, for performance reasons.
Choices
  • 0: Normal
  • 1: No Gibs
  • 2: Full Gibs on All Platforms (Xbox 360, PS3, etc)
  • 3: Reduced gibs
Min Damage to Hurt (minhealthdmg) <integer>
If a single hit to the object doesn't do at least this much damage, the prop won't take any of the damage it attempted to give.
Pressure Delay (PressureDelay) <float>
Seconds to delay breaking from pressure. Allows creaking/groaning sounds to play.
Health (health) <integer>
How close to breaking the object is.
Maximum Health (max_health) <integer>
Health cannot exceed this amount.
Physics Impact Damage Scale (physdamagescale) <float>
Multiplier for damage amount when this entity is hit by a physics object. With a value of 0 the entity will take no damage from physics.
Breakable By (BreakableType) <choices> (only in Left 4 Dead seriesLeft 4 Dead series)
Who can break this?
  • 0: Everyone
  • 1: All Infected
  • 2: Only Tanks
Non-Valve games Black Mesa
Enable Explosion Override (explosion_override) <choices> (only in Black Mesa) !FGD
Enable/disable explosion parameters override (explosion_particle, explosion_particle_liquid, explosion_attachment, explosion_soundscript and explosion_soundscript_liquid).
  • 0: No
  • 1: Yes
Explosion Particle (explosion_particle) <string> (only in Black Mesa) !FGD
A particle system to use when this entity explodes.
Explosion Particle Underwater (explosion_particle_liquid) <string> (only in Black Mesa) !FGD
A particle system to use when this entity explodes in water.
Explosion Attachment Point (explosion_attachment) <string> (only in Black Mesa) !FGD
An attachment point to use for custom explosion particle system.
Note.pngNote:Only for model entities, even despite the fact that this is also present in brush entities.
Explosion Sound Script (explosion_soundscript) <sound> (only in Black Mesa) !FGD
A sound script to use when this entity explodes.
Explosion Sound Script Underwater (explosion_soundscript_liquid) <sound> (only in Black Mesa) !FGD
A sound script to use when this entity explodes in water.
Icon-Important.pngImportant:Both explosion_soundscript and explosion_soundscript_liquid require a sound script, a raw sound file will not work.


{{expand|{{KV Breakable}}|noborder=1}} renders as follows.

Breakable (common):
Performance Mode (PerformanceMode) <choices>
Used to limit the amount of gibs produced when this entity breaks, for performance reasons.
Choices
  • 0: Normal
  • 1: No Gibs
  • 2: Full Gibs on All Platforms (Xbox 360, PS3, etc)
  • 3: Reduced gibs
Min Damage to Hurt (minhealthdmg) <integer>
If a single hit to the object doesn't do at least this much damage, the prop won't take any of the damage it attempted to give.
Pressure Delay (PressureDelay) <float>
Seconds to delay breaking from pressure. Allows creaking/groaning sounds to play.
Health (health) <integer>
How close to breaking the object is.
Maximum Health (max_health) <integer>
Health cannot exceed this amount.
Physics Impact Damage Scale (physdamagescale) <float>
Multiplier for damage amount when this entity is hit by a physics object. With a value of 0 the entity will take no damage from physics.
Breakable By (BreakableType) <choices> (only in Left 4 Dead seriesLeft 4 Dead series)
Who can break this?
  • 0: Everyone
  • 1: All Infected
  • 2: Only Tanks
Non-Valve games Black Mesa
Enable Explosion Override (explosion_override) <choices> (only in Black Mesa) !FGD
Enable/disable explosion parameters override (explosion_particle, explosion_particle_liquid, explosion_attachment, explosion_soundscript and explosion_soundscript_liquid).
  • 0: No
  • 1: Yes
Explosion Particle (explosion_particle) <string> (only in Black Mesa) !FGD
A particle system to use when this entity explodes.
Explosion Particle Underwater (explosion_particle_liquid) <string> (only in Black Mesa) !FGD
A particle system to use when this entity explodes in water.
Explosion Attachment Point (explosion_attachment) <string> (only in Black Mesa) !FGD
An attachment point to use for custom explosion particle system.
Note.pngNote:Only for model entities, even despite the fact that this is also present in brush entities.
Explosion Sound Script (explosion_soundscript) <sound> (only in Black Mesa) !FGD
A sound script to use when this entity explodes.
Explosion Sound Script Underwater (explosion_soundscript_liquid) <sound> (only in Black Mesa) !FGD
A sound script to use when this entity explodes in water.
Icon-Important.pngImportant:Both explosion_soundscript and explosion_soundscript_liquid require a sound script, a raw sound file will not work.


{{expand|color=yellow|title=Yellow|Yellow!}} renders as follows.

Yellow
Yellow!


:{{expand|Can be indented.}} renders as follows.

Can be indented.


{{expand
|title=float{{=}}right
|float=right
|
The title alignment also uses {{param|float}} so that the button stays at the same position when toggling.
}}
float=right

The title alignment also uses {{{float}}} so that the button stays at the same position when toggling.

See how this renders on the right.