2011-12-19 00:19:01 +04:00
|
|
|
#-- encoding: UTF-8
|
2011-12-18 03:50:52 +04:00
|
|
|
#-- 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.
|
|
|
|
#++
|
|
|
|
|
2011-09-10 01:51:02 +04:00
|
|
|
module ChiliProject
|
|
|
|
module Liquid
|
|
|
|
module LiquidExt
|
|
|
|
module Block
|
|
|
|
def self.included(base)
|
|
|
|
base.send(:include, InstanceMethods)
|
|
|
|
base.class_eval do
|
2012-01-16 20:08:52 +04:00
|
|
|
alias_method_chain :render_all, :cleaned_whitespace_and_cache
|
2011-09-10 01:51:02 +04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
module InstanceMethods
|
2012-01-16 20:08:52 +04:00
|
|
|
def render_all_with_cleaned_whitespace_and_cache(list, context)
|
2011-09-10 01:51:02 +04:00
|
|
|
# Remove the leading newline in a block's content
|
|
|
|
list[0].sub!(/\A\r?\n/, "") if list[0].is_a?(String)
|
2012-01-16 20:08:52 +04:00
|
|
|
|
|
|
|
# prevent caching if there are any potentially active elements
|
|
|
|
context.not_cachable! if list.any? { |token| token.respond_to?(:render) }
|
|
|
|
|
|
|
|
render_all_without_cleaned_whitespace_and_cache(list, context)
|
2011-09-10 01:51:02 +04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|