Permalink
Browse files

Merge pull request #156 from ssimeonov/master

Improve API compatibility with ERB templates
  • Loading branch information...
2 parents 10a8ffa + cec5d32 commit 91957e36a8f4912b8d9e167bf7f5faf7d9248add @rtomayko committed Aug 5, 2012
Showing with 6 additions and 1 deletion.
  1. +1 −1 lib/tilt/erb.rb
  2. +5 −0 test/tilt_erbtemplate_test.rb
View
@@ -24,7 +24,7 @@ def initialize_engine
def prepare
@outvar = options[:outvar] || self.class.default_output_variable
- options[:trim] = '<>' if options[:trim].nil? || options[:trim] == true
+ options[:trim] = '<>' if !(options[:trim] == false) && (options[:trim].nil? || options[:trim] == true)
@engine = ::ERB.new(data, options[:safe], options[:trim], @outvar)
end
@@ -89,6 +89,11 @@ class MockOutputVariableScope
end
end
+ test "explicit disabling of trim mode" do
+ template = Tilt::ERBTemplate.new('test.erb', 1, :trim => false) { "\n<%= 1 + 1 %>\n" }
+ assert_equal "\n2\n", template.render
+ end
+
test "default stripping trim mode" do
template = Tilt::ERBTemplate.new('test.erb', 1) { "\n<%= 1 + 1 %>\n" }
assert_equal "\n2", template.render

0 comments on commit 91957e3

Please sign in to comment.