Jump to content

Template:Trim

Permanently protected template
From Meta, a Wikimedia project coordination wiki
This is an archived version of this page, as edited by MusikBot II (talk | contribs) at 18:00, 18 July 2021 (Protected "Template:Trim": High-risk template or module (more info) ([Edit=Allow only autoconfirmed users] (indefinite))). It may differ significantly from the current version.
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Template documentation

Removes spaces and newlines from the start and end.

Usage

Not needed for a named parameter (neither in the template call, nor in the template code). In a template call, even for an unnamed parameter it is usually easier to write it as a named parameter, by putting e.g. "1=" in front. Note however that this affects the numbering of the remaining unnamed parameters.

Also not needed for a parameter of a parser function, it is trimmed anyway.

Even in cases where spaces do not affect rendering, trimming can be useful in substitution to avoid clutter in the resulting wikitext.

Examples

  • "{{trim|abc}}" → "abc" [1]
  • "{{trim|abc }}" → "abc" [2]
  • "{{trim| abc}}" → "abc" [3]
  • "{{trim| abc }}" → "abc" [4]
  • "{{trim|   }}" → "" [5]
  • "{{trim|
    abc
    }}"
    → "abc" [6]
  • {{trim| abc }} gives abc (tabs)