Missed a few :suppress_eval things. Fixed in trunk, soon in stable.

git-svn-id: svn://hamptoncatlin.com/haml/trunk@489 7063305b-7217-0410-af8c-cdc13e5119b9
This commit is contained in:
nex3 2007-04-09 17:03:12 +00:00
parent 439b8c5634
commit b513b5231d
3 changed files with 20 additions and 17 deletions

View File

@ -203,9 +203,9 @@ END
def do_precompile
push_silent <<-END
def _haml_render
@haml_is_haml = true
_hamlout = @haml_stack[-1]
_erbout = _hamlout.buffer
@haml_is_haml = true
_hamlout = @haml_stack[-1]
_erbout = _hamlout.buffer
END
old_line = nil
@ -267,8 +267,7 @@ END
# Close all the open tags
@template_tabs.times { close }
push_silent "@haml_is_haml = false"
push_silent "end"
push_silent "@haml_is_haml = false\nend\n"
end
# Processes and deals with lowering indentation.
@ -314,7 +313,7 @@ END
sub_line = line[1..-1]
unless sub_line[0] == SILENT_COMMENT
mbk = mid_block_keyword?(line)
push_silent(sub_line, !mbk)
push_silent(sub_line, !mbk, true)
if (@block_opened && !mbk) || line[1..-1].split(' ', 2)[0] == "case"
push_and_tabulate([:script])
end
@ -426,12 +425,14 @@ END
# Evaluates <tt>text</tt> in the context of <tt>@scope_object</tt>, but
# does not output the result.
def push_silent(text, add_index = false)
if add_index
@precompiled << "@haml_lineno = #{@index}\n#{text}\n"
else
# Not really DRY, but probably faster
@precompiled << "#{text}\n"
def push_silent(text, add_index = false, can_suppress = false)
unless (can_suppress && options[:suppress_eval])
if add_index
@precompiled << "@haml_lineno = #{@index}\n#{text}\n"
else
# Not really DRY, but probably faster
@precompiled << "#{text}\n"
end
end
end
@ -520,7 +521,7 @@ END
# Closes a Ruby block.
def close_block
push_silent "end"
push_silent "end", false, true
@template_tabs -= 1
end
@ -544,7 +545,7 @@ END
# Closes a loud Ruby block.
def close_loud(command)
push_silent 'end'
push_silent 'end', false, true
@precompiled << command
@template_tabs -= 1
end
@ -593,7 +594,7 @@ END
value_exists = !value.empty?
attributes_hash = "{nil}" if attributes_hash.nil? || @options[:suppress_eval]
object_ref = "nil" unless object_ref
object_ref = "nil" if object_ref.nil? || @options[:suppress_eval]
if !attributes.empty? && '.#'.include?(attributes)
raise SyntaxError.new("Illegal element: classes and ids must have values. Use %div instead.")

View File

@ -57,7 +57,9 @@ class EngineTest < Test::Unit::TestCase
def test_stop_eval
assert_equal("", render("= 'Hello'", :suppress_eval => true))
assert_equal("", render("- puts 'foo'", :suppress_eval => true))
assert_equal("<div id='foo' />\n", render("#foo{:yes => 'no'}/", :suppress_eval => true))
assert_equal("<div />\n", render("%div[1]/", :suppress_eval => true))
begin
assert_equal("", render(":ruby\n puts 'hello'", :suppress_eval => true))

View File

@ -1,5 +1,5 @@
= "not me!"
= "nor me!"
- foo = "not even me!"
%p= foo
- puts "not even me!"
%p= "NO!"
%h1 Me!