Patch Liquid to include filters in a predictable order
This brings us a reliable filter override until https://github.com/Shopify/liquid/pull/87 is accepted and released upstream.
This commit is contained in:
parent
e91a1e010f
commit
9967b5cdf2
|
@ -17,6 +17,8 @@ module ChiliProject
|
|||
module LiquidExt
|
||||
::Liquid::Block.send(:include, Block)
|
||||
::Liquid::Context.send(:include, Context)
|
||||
# Required until https://github.com/Shopify/liquid/pull/87 got merged upstream
|
||||
::Liquid::Strainer.send(:include, Strainer)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -19,6 +19,8 @@ module ChiliProject
|
|||
def self.included(base)
|
||||
base.send(:include, InstanceMethods)
|
||||
base.class_eval do
|
||||
unloadable
|
||||
|
||||
alias_method_chain :render_all, :cleaned_whitespace_and_cache
|
||||
end
|
||||
end
|
||||
|
|
|
@ -19,6 +19,8 @@ module ChiliProject
|
|||
def self.included(base)
|
||||
base.send(:include, InstanceMethods)
|
||||
base.class_eval do
|
||||
unloadable
|
||||
|
||||
alias_method_chain :handle_error, :formatting
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
#-- encoding: UTF-8
|
||||
#-- copyright
|
||||
# ChiliProject is a project management system.
|
||||
#
|
||||
# Copyright (C) 2010-2011 the ChiliProject Team
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# See doc/COPYRIGHT.rdoc for more details.
|
||||
#++
|
||||
|
||||
# Required until https://github.com/Shopify/liquid/pull/87 got merged upstream
|
||||
module ChiliProject
|
||||
module Liquid
|
||||
module LiquidExt
|
||||
module Strainer
|
||||
def self.included(base)
|
||||
base.extend(ClassMethods)
|
||||
base.class_eval do
|
||||
unloadable
|
||||
|
||||
@@filters = []
|
||||
end
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
def global_filter(filter)
|
||||
raise ArgumentError, "Passed filter is not a module" unless filter.is_a?(Module)
|
||||
@@filters << filter
|
||||
end
|
||||
|
||||
def create(context)
|
||||
strainer = self.new(context)
|
||||
@@filters.each { |filter| strainer.extend(filter) }
|
||||
strainer
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue