mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
conditionally build ENGINES constant in respond_with to fix jruby dep issues
- jruby does not support redcarpet(markdown), yajl
This commit is contained in:
parent
a987f3aabb
commit
bbc888647a
2 changed files with 30 additions and 6 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue