mirror of
https://github.com/kemko/liquid.git
synced 2026-01-06 10:15:40 +03:00
Make truncate work for Ruby 1.8
This commit is contained in:
@@ -43,7 +43,8 @@ module Liquid
|
||||
if input.nil? then return end
|
||||
l = length.to_i - truncate_string.length
|
||||
l = 0 if l < 0
|
||||
input.length > length.to_i ? input[0...l] + truncate_string : input
|
||||
truncated = RUBY_VERSION[0,3] == "1.8" ? input.scan(/./mu)[0...l].to_s : input[0...l]
|
||||
input.length > length.to_i ? truncated + truncate_string : input
|
||||
end
|
||||
|
||||
def truncatewords(input, words = 15, truncate_string = "...")
|
||||
|
||||
Reference in New Issue
Block a user