diff --git a/lib/mustache/generator.rb b/lib/mustache/generator.rb index b572bd83..0c88d48c 100644 --- a/lib/mustache/generator.rb +++ b/lib/mustache/generator.rb @@ -105,7 +105,7 @@ def on_section(name, content, raw) Mustache::Template.new(v.call(#{raw.inspect}).to_s).render(ctx.dup) else # Shortcut when passed non-array - v = [v] if v.respond_to?(:has_key?) || !v.respond_to?(:map) || v.is_a?(Struct) + v = [v] unless v.is_a?(Array) || defined?(Enumerator) && v.is_a?(Enumerator) v.map { |h| ctx.push(h); r = #{code}; ctx.pop; r }.join end diff --git a/test/mustache_test.rb b/test/mustache_test.rb index ad83729b..290add48 100644 --- a/test/mustache_test.rb +++ b/test/mustache_test.rb @@ -57,6 +57,15 @@ def test_single_line_sections assert_equal %Q'
{{contact}}
{{/contact}}" + + assert_equal "
Call 1-888-FLOWERS\nAsk for Johnson.
", + instance.render + end + def test_sassy_single_line_sections instance = Mustache.new instance[:full_time] = true