judofyr / temple

Template compilation framework in Ruby
http://judofyr.net/posts/temple.html
MIT License
491 stars 53 forks source link

Upgrading Temple 0.10.0 to 0.10.1 failed my Slim templates #145

Closed olleolleolle closed 1 year ago

olleolleolle commented 1 year ago

Hello,

Apologies. This is a bug report with fuzzy edges.

I updated temple to 0.10.1 from 0.10.0 and I got a

NoMethodError: undefined method `empty?' for nil:NilClass

in Sinatra:

[GEM_ROOT]/gems/sinatra-3.0.6/lib/sinatra/base.rb:947 :in __tilt_9660

Hmm. I pinned temple to 0.10.0, and went on with my day.

I registered a note in the Sinatra Discussions.

scivola commented 1 year ago

I also found this problem.

Here is a minimal reproduction code:

gem "sinatra", "3.0.6"
gem "slim", "5.1.1"
gem "temple", "0.10.1"

require "sinatra"

get "/" do
  slim %(div class="" foo)
end

When we access http://localhost:4567/, we will see NoMethodError.

The exception will be gone by one of the following change:

scivola commented 1 year ago

In version 0.10.1, argument **options was added to the line https://github.com/judofyr/temple/blob/22072c8fbf3b437a7197d77064b80786a056be6e/lib/temple/generator.rb#L58

I found that if options[:save_buffer] is false, the exception will not raise.

minad commented 1 year ago

Can you please confirm that https://github.com/judofyr/temple/commit/0bdacf93e87294e6dd2935c6178071329fa2bcda fixes the issue successfully for you?

scivola commented 1 year ago

https://github.com/judofyr/temple/commit/0bdacf93e87294e6dd2935c6178071329fa2bcda fixes it certainly. Thank you very much.

minad commented 1 year ago

Thanks, I tagged version 0.10.2.

olleolleolle commented 1 year ago

Oh, many thanks, you wonderful people 🙏!