From e82ffeaa0a7a8fe8ba94dc0736c15d05b5746abc Mon Sep 17 00:00:00 2001 From: Artiom Di Date: Wed, 11 Jul 2012 16:36:41 +0300 Subject: Restoring the '%' trim mode for ERb templates, allowing for a leading percent sign on a line to indicate non-inserted Ruby code. --- actionpack/lib/action_view/template/handlers/erb.rb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'actionpack/lib/action_view/template/handlers/erb.rb') diff --git a/actionpack/lib/action_view/template/handlers/erb.rb b/actionpack/lib/action_view/template/handlers/erb.rb index aa8eac7846..4e80c4f456 100644 --- a/actionpack/lib/action_view/template/handlers/erb.rb +++ b/actionpack/lib/action_view/template/handlers/erb.rb @@ -37,6 +37,10 @@ module ActionView end end + class ErubisWithPercentLine < Erubis + include ::Erubis::PercentLineEnhancer + end + class ERB # Specify trim mode for the ERB compiler. Defaults to '-'. # See ERB documentation for suitable values. @@ -76,10 +80,12 @@ module ActionView # Always make sure we return a String in the default_internal erb.encode! - self.class.erb_implementation.new( - erb, - :trim => (self.class.erb_trim_mode == "-") - ).src + mode = self.class.erb_trim_mode.to_s + implementation = self.class.erb_implementation + if mode.include? "%" and implementation == Erubis + implementation = ErubisWithPercentLine + end + implementation.new(erb, :trim => mode.include?("-")).src end private -- cgit v1.2.3