Support Haml 6

Remove use of Haml::Buffer.
This commit is contained in:
Jordan Owens 2022-09-26 11:28:00 -04:00
parent 2b659be947
commit 684a1c0fba
4 changed files with 4 additions and 4 deletions

View File

@ -87,7 +87,7 @@ module Sinatra
def capture(*args, &block)
return block[*args] if ruby?
if haml? && Tilt[:haml] == Tilt::HamlTemplate
if haml? && Tilt[:haml] == Tilt::HamlTemplate && defined?(Haml::Buffer)
buffer = Haml::Buffer.new(nil, Haml::Options.new.for_buffer)
with_haml_buffer(buffer) { capture_haml(*args, &block) }
else

View File

@ -175,7 +175,7 @@ module Sinatra
# for <tt>:head</tt>.
def yield_content(key, *args, &block)
if block_given? && !content_for?(key)
haml? && Tilt[:haml] == Tilt::HamlTemplate ? capture_haml(*args, &block) : yield(*args)
haml? && Tilt[:haml] == Tilt::HamlTemplate && respond_to?(:capture_haml) ? capture_haml(*args, &block) : yield(*args)
else
content = content_blocks[key.to_sym].map { |b| capture(*args, &b) }
content.join.tap do |c|

View File

@ -46,7 +46,7 @@ RubyGems 2.0 or newer is required to protect against public gem pushes. You can
s.add_development_dependency 'asciidoctor'
s.add_development_dependency 'builder'
s.add_development_dependency 'erubi'
s.add_development_dependency 'haml', '~> 5'
s.add_development_dependency 'haml'
s.add_development_dependency 'liquid'
s.add_development_dependency 'markaby'
s.add_development_dependency 'nokogiri'

View File

@ -1 +1 @@
= yield_content :foo, 1, 2
!= yield_content :foo, 1, 2