Template:Trim/doc: Difference between revisions

From HIBIKIFORUM
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Documentation subpage}}
{{Documentation subpage}}
{{template rating|p}}


This template trims leading and trailing (but not interior) whitespace from a string. The string should be passed as the first unnamed parameter. The parameter must be named <code>|1</code> if its value contains a <code>=</code> character.
This template trims leading and trailing (but not interior) whitespace from a string. The string should be passed as the first unnamed parameter. The parameter must be named {{para|1}} if its value contains a {{code|=}} character.


== Usage ==
== Usage ==
<code>{{trim|text}}</code> = text with any leading or trailing whitespace removed.
{{tlc|trim|<var>text</var>}} = <var>text</var> with any leading or trailing whitespace removed.


== Examples ==
== Examples ==
*"<code>{{trim| abc}}</code>" produces "{{trim| abc}}"
* "{{tlc|trim|&nbsp;abc}}" produces "{{trim| abc}}"
*"<code>{{trim|xyz&nbsp;}}</code>" produces "{{trim|xyz }}"
* "{{tlc|trim|xyz&nbsp;}}" produces "{{trim|xyz }}"
*"<code>{{trim| abc xyz&nbsp;}}</code>" produces "{{trim| abc xyz }}"
* "{{tlc|trim|&nbsp;abc xyz&nbsp;}}" produces "{{trim| abc xyz }}"


== Template data ==
== Template data ==
Line 27: Line 26:
</templatedata>
</templatedata>


<includeonly>
<includeonly>{{sandbox other||{{testcases other||
 
<!-- Categories below this line, please -->
<!-- Categories below this line, please -->
[[Category:Templates]]
[[Category:Formatting templates]]
</includeonly>
}}}}</includeonly>

Latest revision as of 02:08, 20 August 2023

Light bulb.png }}
It contains usage information, categories and other content that is not part of the original template page.

This template trims leading and trailing (but not interior) whitespace from a string. The string should be passed as the first unnamed parameter. The parameter must be named |1= if its value contains a {{{1}}} character.

Usage

{{trim|text}} = text with any leading or trailing whitespace removed.

Examples

  • "{{trim| abc}}" produces "abc"
  • "{{trim|xyz }}" produces "xyz"
  • "{{trim| abc xyz }}" produces "abc xyz"

Template data

The template trims whitespace from a string.

Template parameters

ParameterDescriptionTypeStatus
String1

The string to be trimmed of whitespace

Stringrequired