Template:Trim
Jump to navigation
Jump to search
[edit] [ ] Template documentation
This documentation is transcluded from Template:Trim/doc. (edit | history)
Editors can experiment in this template's sandbox (create) and test cases (create) pages.
Subpages of this template.
Editors can experiment in this template's sandbox (create) and test cases (create) pages.
Subpages of this template.
Description
Trims whitespace (regular spaces, tabs, new lines) from the beginning and end of its input. Can be used for text, but is more useful for templates.
Usage
{{Trim|input}}
Examples
Text
"{{Trim| Example text }}
"
"Example text"
Images
A new line in an image link will prevent it from being rendered:
[[File: Example.jpg|100px]]
[[File: Example.jpg|100px]]
But when trimmed:
[[File:{{trim| Example.jpg}}|100px]]
Templates
A template wishing to accept block-layout arguments must trim input of any unnamed (numbered) parameters for exactly the same reason:
{{some image handling template|[[File:{{trim|{{{1}}}}}]]}}
Won't break when called as:
{{some image handling template | Example.jpg }}
History
Was originally called Template:StripWhitespace here. Subsequently updated to use Wikipedia's template code, and renamed to Template:Trim.