diff --git a/lib/chili_project/liquid/filters.rb b/lib/chili_project/liquid/filters.rb
index 28faa5b4..469f3900 100644
--- a/lib/chili_project/liquid/filters.rb
+++ b/lib/chili_project/liquid/filters.rb
@@ -13,6 +13,38 @@
module ChiliProject
module Liquid
+ module OverriddenFilters
+ # These filters are defined in liquid core but are overwritten here
+ # to improve on their implementation
+
+ # Split input string into an array of substrings separated by given pattern.
+ # Default to whitespace
+ def split(input, pattern=nil)
+ input.split(pattern)
+ end
+
+ def strip_newlines(input)
+ input.to_s.gsub(/\r?\n/, '')
+ end
+
+ # Add
tags in front of all newlines in input string
+ def newline_to_br(input)
+ input.to_s.gsub(/(\r?\n)/, "
\1")
+ end
+
+ # Use the block systax for sub and gsub to prevent interpretation of
+ # backreferences
+ # See https://gist.github.com/1491437
+ def replace(input, string, replacement = '')
+ input.to_s.gsub(string){replacement}
+ end
+
+ # Replace the first occurrences of a string with another
+ def replace_first(input, string, replacement = '')
+ input.to_s.sub(string){replacement}
+ end
+ end
+
module Filters
def default(input, default)
input.to_s.strip.present? ? input : default
@@ -23,6 +55,7 @@ module ChiliProject
end
end
+ Template.register_filter(OverriddenFilters)
Template.register_filter(Filters)
end
end