diff --git a/lib/haml/template.rb b/lib/haml/template.rb index 6ad7d653..4c27df44 100644 --- a/lib/haml/template.rb +++ b/lib/haml/template.rb @@ -46,9 +46,7 @@ module Haml # with local_assigns available as local variables within the template. # Returns the result as a string. def render(template, local_assigns={}) - @view.instance_eval do - evaluate_assigns - end + @view.send(:evaluate_assigns) options = @@options.dup locals = options[:locals] || {} @@ -67,7 +65,6 @@ module Haml end engine.to_html(@view) { |*args| yield_proc.call(*args) } - end end end diff --git a/test/benchmark.rb b/test/benchmark.rb index 75b3baf6..1fa3ebe4 100644 --- a/test/benchmark.rb +++ b/test/benchmark.rb @@ -72,8 +72,8 @@ module Haml ActionView::Base.register_template_handler("haml", Haml::Template) @base = ActionView::Base.new(File.dirname(__FILE__)) times = Benchmark.bmbm do |b| - b.report("haml:") { runs.times { @base.render 'haml/templates/standard' } } - b.report("erb:") { runs.times { @base.render 'haml/rhtml/standard' } } + b.report("haml:") { runs.times { @base.render 'haml/templates/action_view' } } + b.report("erb:") { runs.times { @base.render 'haml/rhtml/action_view' } } end print_result["ERB", 1] diff --git a/test/haml/rhtml/_av_partial_1.rhtml b/test/haml/rhtml/_av_partial_1.rhtml new file mode 100644 index 00000000..7507a0be --- /dev/null +++ b/test/haml/rhtml/_av_partial_1.rhtml @@ -0,0 +1,12 @@ +

This is a pretty complicated partial

+
+

It has several nested partials,

+ +
diff --git a/test/haml/rhtml/_av_partial_2.rhtml b/test/haml/rhtml/_av_partial_2.rhtml new file mode 100644 index 00000000..e884a348 --- /dev/null +++ b/test/haml/rhtml/_av_partial_2.rhtml @@ -0,0 +1,8 @@ +<% @nesting -= 1 %> +
+

This is a crazy deep-nested partial.

+

Nesting level <%= @nesting %>

+ <% if @nesting > 0 %> + <%= render :partial => 'haml/rhtml/av_partial_2' %> + <% end %> +
diff --git a/test/haml/rhtml/action_view.rhtml b/test/haml/rhtml/action_view.rhtml new file mode 100644 index 00000000..bcb0d416 --- /dev/null +++ b/test/haml/rhtml/action_view.rhtml @@ -0,0 +1,62 @@ + + + + Hampton Catlin Is Totally Awesome + + + +

+ This is very much like the standard template, + except that it has some ActionView-specific stuff. + It's only used for benchmarking. +

+
+ <%= render :partial => 'haml/rhtml/av_partial_1' %> +
+ +
+ Yes, ladies and gentileman. He is just that egotistical. + Fantastic! This should be multi-line output + The question is if this would translate! Ahah! + <%= 1 + 9 + 8 + 2 %> + <%# numbers should work and this should be ignored %> +
+ <% 120.times do |number| -%> + <%= number %> + <% end -%> +
<%= " Quotes should be loved! Just like people!" %>
+ Wow. +

+ <%= "Holy cow " + + "multiline " + + "tags! " + + "A pipe (|) even!" %> + <%= [1, 2, 3].collect { |n| "PipesIgnored|" } %> + <%= [1, 2, 3].collect { |n| + n.to_s + }.join("|") %> +

+
+ <% foo = String.new + foo << "this" + foo << " shouldn't" + foo << " evaluate" %> + <%= foo + "but now it should!" %> + <%# Woah crap a comment! %> +
+