Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Failing test for #87

  • Loading branch information...
commit 0f89d738940cce3dd24b6137fe94d2d7528fd59e 1 parent ee6c868
@defunkt defunkt authored
Showing with 7 additions and 0 deletions.
  1. +7 −0 test/mustache_test.rb
View
7 test/mustache_test.rb
@@ -74,6 +74,13 @@ def test_sassy_single_line_sections
assert_equal "\n full time\n", instance.render
end
+ def test_sassier_single_line_sections
+ instance = Mustache.new
+ instance.template = "\t{{#list}}\r\n\t{{/list}}"
+
+ assert_equal "", instance.render
+ end
+
def test_two_line_sections
html = %(<p class="flash-notice" {{# no_flash }}style="display: none;"\n{{/ no_flash }}>)

3 comments on commit 0f89d73

@judofyr

Is this expected behaviour?

m = Mustache.new
m.template = " {{#list}} \nHello{{/list}}"
p m.render(:list => [1, 2])
# => "  \nHello  \nHello"

AST:

[:multi,
 [:mustache,
  :section,
  [:mustache, :fetch, ["list"]],
  [:multi, [:static, " "], [:static, " \nHello"]],
  " \nHello"]]

I would expect that the whitespace before the opening tag should not be a part of the section, but rather be inserted before the section tag.

@judofyr

I've pushed a fix for this test and a fix/test for the comment above. All tests pass (including the Mustache specs). I'll leave #87 open until you decide if this is the right solution.

@pvande

This is not the first bug of this class that we've seen; I'll push some new tests into the spec so that future implementations don't hit the same potholes.

Please sign in to comment.
Something went wrong with that request. Please try again.