diff --git a/lib/haml/helpers/action_view_mods.rb b/lib/haml/helpers/action_view_mods.rb index 7303231d..0eb3e2b1 100644 --- a/lib/haml/helpers/action_view_mods.rb +++ b/lib/haml/helpers/action_view_mods.rb @@ -103,7 +103,7 @@ if defined?(ActionView) and not defined?(Merb::Plugins) preserve = haml_buffer.options[:preserve].include?(name.to_s) - if block_given? && block_called_from_erb?(block) && preserve + if block_given? && block_is_haml?(block) && preserve return content_tag_without_haml(name, *args) {preserve(&block)} end diff --git a/test/haml/engine_test.rb b/test/haml/engine_test.rb index 49b39a42..191c5186 100644 --- a/test/haml/engine_test.rb +++ b/test/haml/engine_test.rb @@ -302,23 +302,23 @@ HAML end def test_escaped_inline_string_interpolation - assert_equal("

4&3

\n", render("%p&== #{2+2}&#{2+1}", :escape_html => true)) - assert_equal("

4&3

\n", render("%p&== #{2+2}&#{2+1}", :escape_html => false)) + assert_equal("

4&3

\n", render("%p&== \#{2+2}&\#{2+1}", :escape_html => true)) + assert_equal("

4&3

\n", render("%p&== \#{2+2}&\#{2+1}", :escape_html => false)) end def test_unescaped_inline_string_interpolation - assert_equal("

4&3

\n", render("%p!== #{2+2}&#{2+1}", :escape_html => true)) - assert_equal("

4&3

\n", render("%p!== #{2+2}&#{2+1}", :escape_html => false)) + assert_equal("

4&3

\n", render("%p!== \#{2+2}&\#{2+1}", :escape_html => true)) + assert_equal("

4&3

\n", render("%p!== \#{2+2}&\#{2+1}", :escape_html => false)) end def test_escaped_string_interpolation - assert_equal("

\n 4&3\n

\n", render("%p\n &== #{2+2}&#{2+1}", :escape_html => true)) - assert_equal("

\n 4&3\n

\n", render("%p\n &== #{2+2}&#{2+1}", :escape_html => false)) + assert_equal("

\n 4&3\n

\n", render("%p\n &== \#{2+2}&\#{2+1}", :escape_html => true)) + assert_equal("

\n 4&3\n

\n", render("%p\n &== \#{2+2}&\#{2+1}", :escape_html => false)) end def test_unescaped_string_interpolation - assert_equal("

\n 4&3\n

\n", render("%p\n !== #{2+2}&#{2+1}", :escape_html => true)) - assert_equal("

\n 4&3\n

\n", render("%p\n !== #{2+2}&#{2+1}", :escape_html => false)) + assert_equal("

\n 4&3\n

\n", render("%p\n !== \#{2+2}&\#{2+1}", :escape_html => true)) + assert_equal("

\n 4&3\n

\n", render("%p\n !== \#{2+2}&\#{2+1}", :escape_html => false)) end def test_scripts_should_respect_escape_html_option diff --git a/test/haml/template_test.rb b/test/haml/template_test.rb index 97aeaf9e..ce41931b 100644 --- a/test/haml/template_test.rb +++ b/test/haml/template_test.rb @@ -4,6 +4,8 @@ require 'haml/template' require 'sass/plugin' require File.dirname(__FILE__) + '/mocks/article' +require 'action_pack/version' + module Haml::Filters::Test include Haml::Filters::Base @@ -28,8 +30,10 @@ class TemplateTest < Test::Unit::TestCase TEMPLATE_PATH = File.join(File.dirname(__FILE__), "templates") TEMPLATES = %w{ very_basic standard helpers whitespace_handling original_engine list helpful - silent_script tag_parsing just_stuff partials partial_layout + silent_script tag_parsing just_stuff partials filters nuke_outer_whitespace nuke_inner_whitespace } + # partial layouts were introduced in 2.0.0 + TEMPLATES << 'partial_layout' unless ActionPack::VERSION::MAJOR < 2 def setup vars = { 'article' => Article.new, 'foo' => 'value one' } @@ -70,7 +74,7 @@ class TemplateTest < Test::Unit::TestCase end def assert_renders_correctly(name, &render_method) - render_method ||= proc { |name| @base.render(name) } + render_method ||= proc { |name| @base.render(:file => name) } load_result(name).split("\n").zip(render_method[name].split("\n")).each_with_index do |pair, line| message = "template: #{name}\nline: #{line}" diff --git a/test/haml/templates/helpers.haml b/test/haml/templates/helpers.haml index f4643ea8..cec95aa1 100644 --- a/test/haml/templates/helpers.haml +++ b/test/haml/templates/helpers.haml @@ -35,20 +35,43 @@ click %p boom - concat "foo\n" - haml_buffer.tabulation = 0 -- def url_for(*stuff); stuff.join(' '); end --# The form URLs must be empty --# because of a weird bug that causes url_for to misbehave. -%p - = form_tag '' -- form_tag '' do - %div= submit_tag 'save' - - @foo = 'value one' - = test_partial 'partial' -- form_for :article, @article, :url => '' do |f| - Title: - = f.text_field :title - Body: - = f.text_field :body +-# +-# ActionPack pre-2.0 has weird url_for issues here. +- if ActionPack::VERSION::MAJOR < 2 + :plain +

+

+

+ +
+

+ @foo = + value one +

+ Toplevel? false +

+ @foo = + value three +

+
+
+ Title: + + Body: + +
+- else + %p + = form_tag '' + - form_tag '' do + %div= submit_tag 'save' + - @foo = 'value one' + = test_partial 'partial' + - form_for :article, @article, :url => '' do |f| + Title: + = f.text_field :title + Body: + = f.text_field :body = list_of({:google => 'http://www.google.com'}) do |name, link| %a{ :href => link }= name %p