Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


NoMethodError starting with 0.12.1 #87

stoodfarback opened this Issue · 5 comments

3 participants


0.12.0 works fine
0.12.1 and higher are broken

ruby-1.9.2-p180 > Mustache.render("\t{{#list}}\r\n\t{{/list}}")
NoMethodError: undefined method first' for nil:NilClass
from ******/.rvm/gems/ruby-1.9.2-p180/gems/mustache-0.99.1/lib/mustache/generator.rb:79:in
from ***/.rvm/gems/ruby-1.9.2-p180/gems/mustache-0.99.1/lib/mustache/generator.rb:81:in `block in compile!'
from *
/.rvm/gems/ruby-1.9.2-p180/gems/mustache-0.99.1/lib/mustache/generator.rb:81:in `map'
from **
/.rvm/gems/ruby-1.9.2-p180/gems/mustache-0.99.1/lib/mustache/generator.rb:81:in `compile!'
from **
/.rvm/gems/ruby-1.9.2-p180/gems/mustache-0.99.1/lib/mustache/generator.rb:37:in `compile'
from **
/.rvm/gems/ruby-1.9.2-p180/gems/mustache-0.99.1/lib/mustache/template.rb:49:in `compile'
from **
/.rvm/gems/ruby-1.9.2-p180/gems/mustache-0.99.1/lib/mustache/template.rb:35:in `render'
from **
/.rvm/gems/ruby-1.9.2-p180/gems/mustache-0.99.1/lib/mustache.rb:119:in `render'
from **
/.rvm/gems/ruby-1.9.2-p180/gems/mustache-0.99.1/lib/mustache.rb:84:in `render'
from (irb):19
from **
**/.rvm/rubies/ruby-1.9.2-p180/bin/irb:17:in `



Added a failing test in 0f89d73


This exact issue should be fixed by 0.99.2 :-)


current behavior on 0.99.2:
ruby-1.9.2-p180 > Mustache.render("\t{{#list}}\r\n\t{{/list}}")
=> ""
ruby-1.9.2-p180 > Mustache.render("\t{{#list}}\r\n\t{{/list}}", :list => [1,2])
=> "\t\t"
ruby-1.9.2-p180 > Mustache.render("\t")
=> "\t"

why is the first '\t' removed from the first two examples? and in the second example, why is '\r\n' not repeated like '\t' is?


When a section-tag is the only part of a line (with optional whitespace at the beginning), the whitespace should be stripped. That's why the \r\n is not repeated and the \t is removed. In the last example there's not a tag involved, so Mustache doesn't do anything about it.

Actually, I think that the repeated \t in example 2 is a bug. I would expect it to strip the padding because the closing-tag is the only part of the line. We need to do a check for @scanner.eos? where we insert the padding again. I'll try to fix this later.


After de3409f, the two first examples both return an empty string as explained (and expected) above.

@brianjlandau brianjlandau referenced this issue from a commit in brianjlandau/mustache
@defunkt defunkt Failing test for #87 0f89d73
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.