Simply push_text now that it doesn't have to deal with one liners.

Extra test to make sure one liner related stuff is getting done.


git-svn-id: svn://hamptoncatlin.com/haml/trunk@558 7063305b-7217-0410-af8c-cdc13e5119b9
This commit is contained in:
tom 2007-07-13 04:39:13 +00:00
parent d4fcabbcf9
commit 14c04240e4
2 changed files with 9 additions and 12 deletions

View File

@ -43,19 +43,12 @@ module Haml
# Renders +text+ with the proper tabulation. This also deals with
# making a possible one-line tag one line or not.
def push_text(text, tab_change = 0, try_one_liner = false)
if @one_liner_pending && Buffer.one_liner?(text)
@buffer << text
else
if @one_liner_pending
@buffer << "\n"
@one_liner_pending = false
end
if(@tabulation > 0)
text.gsub!(/^/m, ' ' * @tabulation)
end
@buffer << "#{text}"
if(@tabulation > 0)
# Have to push every line in by the extra user set tabulation
text.gsub!(/^/m, ' ' * @tabulation)
end
@buffer << "#{text}"
@real_tabs += tab_change
@one_liner_pending = try_one_liner
end

View File

@ -45,6 +45,10 @@ class EngineTest < Test::Unit::TestCase
def test_long_liner_should_not_print_on_one_line
assert_equal("<div>\n #{'x' * 51}\n</div>", render("%div #{'x' * 51}").chomp)
end
def test_non_prerendered_one_liner
assert_equal("<p class='awesome'>One line</p>\n", render("%p{:class => c} One line", :locals => {:c => 'awesome'}))
end
def test_multi_render
engine = Haml::Engine.new("%strong Hi there!")