From f206f7e3933dddd93df75b29085beb5a42bef847 Mon Sep 17 00:00:00 2001 From: Mostafa Ahangarha Date: Thu, 14 Nov 2024 12:49:25 +0330 Subject: [PATCH] Simplify the logic --- lib/liquid/standardfilters.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/liquid/standardfilters.rb b/lib/liquid/standardfilters.rb index bf3f113df..2d66875c9 100644 --- a/lib/liquid/standardfilters.rb +++ b/lib/liquid/standardfilters.rb @@ -285,10 +285,10 @@ def truncatewords(input, words = 15, truncate_string = "...") # @liquid_category string # @liquid_summary # Splits a string into an array of substrings based on a given separator and an optional limit number - # @liquid_syntax string | split: string + # @liquid_syntax string | split: string, integer # @liquid_return [array[string]] def split(input, pattern, limit = nil) - limit = limit.respond_to?(:to_i) ? limit.to_i : 0 + limit = Utils.to_number(limit).to_i input.to_s.split(pattern.to_s, limit) end