mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
Remove outdated code for Tilt 1.x versions support
I found out that Sinatra codebase still contains code for handling both versions of Tilt (1.x and 2.x), however starting from Sinatra 2.0 the minimally required version of Tilt is 2.0 as well. This commit removes old code and cleans up a bit how tests for different markdown engines are generated.
This commit is contained in:
parent
5e2e41f283
commit
1d19193653
2 changed files with 10 additions and 16 deletions
|
@ -786,17 +786,10 @@ module Sinatra
|
|||
def find_template(views, name, engine)
|
||||
yield ::File.join(views, "#{name}.#{@preferred_extension}")
|
||||
|
||||
if Tilt.respond_to?(:mappings)
|
||||
Tilt.mappings.each do |ext, engines|
|
||||
next unless ext != @preferred_extension and engines.include? engine
|
||||
yield ::File.join(views, "#{name}.#{ext}")
|
||||
end
|
||||
else
|
||||
Tilt.default_mapping.extensions_for(engine).each do |ext|
|
||||
yield ::File.join(views, "#{name}.#{ext}") unless ext == @preferred_extension
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
|
|
|
@ -69,17 +69,18 @@ MarkdownTest = proc do
|
|||
end
|
||||
|
||||
# Will generate RDiscountTest, KramdownTest, etc.
|
||||
map = Tilt.respond_to?(:lazy_map) ? Tilt.lazy_map['md'].map(&:first) : Tilt.mappings['md']
|
||||
markdown_templates = Tilt.lazy_map['md'].map { |klass, _require_path| klass }
|
||||
|
||||
map.each do |t|
|
||||
markdown_templates.each do |template_name|
|
||||
begin
|
||||
t = eval(t) if t.is_a? String
|
||||
t.new { "" }
|
||||
klass = Class.new(Minitest::Test) { define_method(:engine) { t }}
|
||||
template = Object.const_get(template_name)
|
||||
|
||||
klass = Class.new(Minitest::Test) { define_method(:engine) { template } }
|
||||
klass.class_eval(&MarkdownTest)
|
||||
name = t.name[/[^:]+$/].sub(/Template$/, '') << "Test"
|
||||
|
||||
name = template_name.split('::').last.sub(/Template$/, 'Test')
|
||||
Object.const_set name, klass
|
||||
rescue LoadError, NameError
|
||||
warn "#{$!}: skipping markdown tests with #{t}"
|
||||
warn "#{$!}: skipping markdown tests with #{template_name}"
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue