Add squish filter

This commit is contained in:
Michaël Gallego
2026-02-19 10:03:52 +09:00
parent d897899f66
commit d589c51697
2 changed files with 20 additions and 0 deletions
+13
View File
@@ -293,6 +293,19 @@ module Liquid
input.split(pattern)
end
# @liquid_public_docs
# @liquid_type filter
# @liquid_category string
# @liquid_summary
# Removes leading and trailing whitespace and collapses consecutive whitespace to a single space.
# @liquid_syntax string | squish
# @liquid_return [string]
def squish(input)
return if input.nil?
Utils.to_s(input).strip.gsub(/\s+/, ' ')
end
# @liquid_public_docs
# @liquid_type filter
# @liquid_category string