Fixes a bug where calling Engine#to_html multiple times on the same Engine object duplicated the text

each time.


git-svn-id: svn://hamptoncatlin.com/haml/branches/edge@102 7063305b-7217-0410-af8c-cdc13e5119b9
This commit is contained in:
nex3 2006-10-27 20:48:40 +00:00
parent 47616c9c97
commit aa9289b9cc
2 changed files with 8 additions and 2 deletions

View File

@ -100,8 +100,6 @@ module Haml
options.each { |k,v| eval("@#{k} = v") } options.each { |k,v| eval("@#{k} = v") }
@template = template #String @template = template #String
@buffer = Haml::Buffer.new
@to_close_stack = [] @to_close_stack = []
@tabulation = 0 @tabulation = 0
@ -114,6 +112,7 @@ module Haml
# a string. # a string.
def to_html(scope = Object.new, &block) def to_html(scope = Object.new, &block)
@scope_object = scope @scope_object = scope
@buffer = Haml::Buffer.new
# Compile the @precompiled buffer # Compile the @precompiled buffer
compile &block compile &block

View File

@ -48,4 +48,11 @@ class EngineTest < Test::Unit::TestCase
def test_long_liner_should_not_print_on_one_line def test_long_liner_should_not_print_on_one_line
assert_equal("<div>\n #{'x' * 51}\n</div>", render("%div #{'x' * 51}").chomp) assert_equal("<div>\n #{'x' * 51}\n</div>", render("%div #{'x' * 51}").chomp)
end end
def test_multi_render
engine = Haml::Engine.new("%strong Hi there!")
assert_equal("<strong>Hi there!</strong>\n", engine.to_html)
assert_equal("<strong>Hi there!</strong>\n", engine.to_html)
assert_equal("<strong>Hi there!</strong>\n", engine.to_html)
end
end end