strip
Remove all leading and trailing whitespace characters from both ends of a string.
Syntax
{{ string | strip }}Example
{% assign text = " Clean Both Sides " %}[{{ text | strip }}]Output
[Clean Both Sides]The strip filter removes all leading and trailing whitespace, tab, and newline characters from both ends of a string, preserving internal word spacing perfectly.
On keyword combination landing pages, strip sanitizes individual items parsed by split from human-entered spreadsheets where spaces frequently follow commas. For example: {% for item in row.tags | split: ',' %}<span>{{ item | strip }}</span>{% endfor %}. This ensures HTML badge elements have neat padding and no accidental margin offsets.
Filters
- abs
- append
- at_least
- at_most
- capitalize
- ceil
- compact
- concat
- date
- default
- divided_by
- downcase
- escape
- escape_once
- first
- floor
- join
- last
- lstrip
- map
- minus
- modulo
- newline_to_br
- plus
- prepend
- remove
- remove_first
- replace
- replace_first
- reverse
- round
- rstrip
- size
- slice
- sort
- sort_natural
- split
- strip
- strip_html
- strip_newlines
- times
- truncate
- truncatewords
- uniq
- upcase
- url_decode
- url_encode
- where
- raw
- slugify
- number_format
