diff --git a/sinatra-contrib/Gemfile b/sinatra-contrib/Gemfile index ddb2165d..915043cd 100644 --- a/sinatra-contrib/Gemfile +++ b/sinatra-contrib/Gemfile @@ -16,13 +16,13 @@ group :development, :test do platform :jruby, :ruby do gem 'slim', '2.1.0' + gem 'liquid', '2.6.1' end platform :ruby do gem 'execjs', '2.0.0' gem 'nokogiri', '1.5.10' gem 'redcarpet', '2.3.0' - gem 'liquid', '2.6.1' gem 'yajl-ruby' gem 'therubyracer' end diff --git a/sinatra-contrib/lib/sinatra/respond_with.rb b/sinatra-contrib/lib/sinatra/respond_with.rb index c6455b39..95da1487 100644 --- a/sinatra-contrib/lib/sinatra/respond_with.rb +++ b/sinatra-contrib/lib/sinatra/respond_with.rb @@ -227,19 +227,43 @@ module Sinatra super end + def self.all + engines = Sinatra::Templates.instance_methods.map(&:to_sym) + [:mab] - + [:find_template, :markaby] + if defined? JRUBY_VERSION + jrubyify(engines) + end + engines + end + + def self.html + engines = [:erb, :erubis, :haml, :slim, :liquid, :radius, :mab, :markdown, + :textile, :rdoc] + if defined? JRUBY_VERSION + jrubyify(engines) + end + engines + end + + def self.jrubyify(engs) + not_supported = [:yajl, :markdown] + engs.delete_if { |eng| not_supported.include?(eng) } + end + ENGINES = { :css => [:less, :sass, :scss], :xml => [:builder, :nokogiri], :js => [:coffee], - :json => [:yajl], - :html => [:erb, :erubis, :haml, :slim, :liquid, :radius, :mab, :markdown, - :textile, :rdoc], - :all => Sinatra::Templates.instance_methods.map(&:to_sym) + [:mab] - - [:find_template, :markaby] + :html => html, + :all => all } + (defined? JRUBY_VERSION) ? (ENGINES[:json] = [:json_pure]) : (ENGINES[:json] = [:yajl]) + ENGINES.default = [] + puts ENGINES.inspect + def self.registered(base) base.set :ext_map, Hash.new { |h,k| h[k] = [] } base.set :template_engines, ENGINES.dup