mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-12 15:30:39 -07:00
slice filter
This commit is contained in:
@@ -36,12 +36,15 @@ module Liquid
|
||||
def escape(input)
|
||||
CGI.escapeHTML(input) rescue input
|
||||
end
|
||||
alias_method :h, :escape
|
||||
|
||||
def escape_once(input)
|
||||
input.to_s.gsub(HTML_ESCAPE_ONCE_REGEXP, HTML_ESCAPE)
|
||||
end
|
||||
|
||||
alias_method :h, :escape
|
||||
def slice(input, offset, length=nil)
|
||||
input.to_s.slice(offset.to_i, (length || 1).to_i) || ''
|
||||
end
|
||||
|
||||
# Truncate a string down to x characters
|
||||
def truncate(input, length = 50, truncate_string = "...".freeze)
|
||||
|
||||
Reference in New Issue
Block a user