diff --git a/Appraisals b/Appraisals index 01931b0..4eae78d 100644 --- a/Appraisals +++ b/Appraisals @@ -11,7 +11,3 @@ end appraise 'sprockets-4_0' do gem 'sprockets', '4.0.3' end - -appraise 'tilt-2' do - gem 'tilt', '2.4.0' -end diff --git a/gemfiles/rails_4_1.gemfile b/gemfiles/rails_4_1.gemfile deleted file mode 100644 index 9fff30b..0000000 --- a/gemfiles/rails_4_1.gemfile +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -# This file was generated by Appraisal - -source 'http://rubygems.org' - -gem 'rails', '4.1.14' -gem 'rails-sprockets', '2.3.3' - -gemspec path: '../' diff --git a/gemfiles/rails_4_2.gemfile b/gemfiles/rails_4_2.gemfile deleted file mode 100644 index d3802cb..0000000 --- a/gemfiles/rails_4_2.gemfile +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -# This file was generated by Appraisal - -source 'http://rubygems.org' - -gem 'rails', '4.2.5' -gem 'rails-sprockets', '2.3.3' - -gemspec path: '../' diff --git a/gemfiles/rails_5.gemfile b/gemfiles/rails_5.gemfile deleted file mode 100644 index 53629ec..0000000 --- a/gemfiles/rails_5.gemfile +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -# This file was generated by Appraisal - -source 'http://rubygems.org' - -gem 'rails', '5.0.0.beta1' -gem 'rails-sprockets', '3.0.0' - -gemspec path: '../' diff --git a/gemfiles/sprockets_2.gemfile b/gemfiles/sprockets_2.gemfile deleted file mode 100644 index d05242d..0000000 --- a/gemfiles/sprockets_2.gemfile +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -# This file was generated by Appraisal - -source 'http://rubygems.org' - -gem 'sprockets', '2.3.3' - -gemspec path: '../' diff --git a/gemfiles/sprockets_3.gemfile b/gemfiles/sprockets_3.gemfile deleted file mode 100644 index 8109187..0000000 --- a/gemfiles/sprockets_3.gemfile +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -# This file was generated by Appraisal - -source 'http://rubygems.org' - -gem 'sprockets', '3.7.0' - -gemspec path: '../' diff --git a/gemfiles/sprockets_4_0.gemfile b/gemfiles/sprockets_4_0.gemfile index 8f0399f..6804884 100644 --- a/gemfiles/sprockets_4_0.gemfile +++ b/gemfiles/sprockets_4_0.gemfile @@ -1,9 +1,14 @@ -# frozen_string_literal: true - # This file was generated by Appraisal -source 'http://rubygems.org' +source "http://rubygems.org" -gem 'sprockets', '4.0.3' +gem "appraisal" +gem "haml", "~> 6.3" +gem "slim", "~> 5.2" +gem "minitest", "~> 5.25" +gem "rake", "~> 13.2" +gem "rubocop", require: false +gem "rubocop-rake", require: false +gem "sprockets", "4.0.3" -gemspec path: '../' +gemspec path: "../" diff --git a/gemfiles/sprockets_4_1.gemfile b/gemfiles/sprockets_4_1.gemfile index 676d3ef..bb895b8 100644 --- a/gemfiles/sprockets_4_1.gemfile +++ b/gemfiles/sprockets_4_1.gemfile @@ -1,9 +1,14 @@ -# frozen_string_literal: true - # This file was generated by Appraisal -source 'http://rubygems.org' +source "http://rubygems.org" -gem 'sprockets', '4.1.1' +gem "appraisal" +gem "haml", "~> 6.3" +gem "slim", "~> 5.2" +gem "minitest", "~> 5.25" +gem "rake", "~> 13.2" +gem "rubocop", require: false +gem "rubocop-rake", require: false +gem "sprockets", "4.1.1" -gemspec path: '../' +gemspec path: "../" diff --git a/gemfiles/sprockets_4_2.gemfile b/gemfiles/sprockets_4_2.gemfile index c7bcb7f..266bbeb 100644 --- a/gemfiles/sprockets_4_2.gemfile +++ b/gemfiles/sprockets_4_2.gemfile @@ -1,9 +1,14 @@ -# frozen_string_literal: true - # This file was generated by Appraisal -source 'http://rubygems.org' +source "http://rubygems.org" -gem 'sprockets', '4.2.1' +gem "appraisal" +gem "haml", "~> 6.3" +gem "slim", "~> 5.2" +gem "minitest", "~> 5.25" +gem "rake", "~> 13.2" +gem "rubocop", require: false +gem "rubocop-rake", require: false +gem "sprockets", "4.2.1" -gemspec path: '../' +gemspec path: "../" diff --git a/gemfiles/tilt_1.gemfile b/gemfiles/tilt_1.gemfile deleted file mode 100644 index 67836b2..0000000 --- a/gemfiles/tilt_1.gemfile +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -# This file was generated by Appraisal - -source 'http://rubygems.org' - -gem 'tilt', '1.4.1' - -gemspec path: '../' diff --git a/gemfiles/tilt_2.gemfile b/gemfiles/tilt_2.gemfile deleted file mode 100644 index f793f61..0000000 --- a/gemfiles/tilt_2.gemfile +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -# This file was generated by Appraisal - -source 'http://rubygems.org' - -gem 'tilt', '2.4.0' - -gemspec path: '../' diff --git a/handlebars_assets.gemspec b/handlebars_assets.gemspec index f5647fb..e0acd7c 100644 --- a/handlebars_assets.gemspec +++ b/handlebars_assets.gemspec @@ -22,7 +22,6 @@ Gem::Specification.new do |s| s.add_dependency 'execjs', '~> 2.10' s.add_dependency 'sprockets', '>= 4.0' - s.add_dependency 'tilt', '>= 2.4' s.post_install_message = 'Remember to rake assets:clean or rake assets:purge on update! this is required because of handlebars updates' s.metadata['rubygems_mfa_required'] = 'true' diff --git a/lib/handlebars_assets/handlebars_template.rb b/lib/handlebars_assets/handlebars_template.rb index 4ea19ea..4fda1ac 100644 --- a/lib/handlebars_assets/handlebars_template.rb +++ b/lib/handlebars_assets/handlebars_template.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -require 'English' -require 'tilt' require 'json' module HandlebarsAssets @@ -15,32 +13,6 @@ def unindent(heredoc) end end - # Sprockets <= 3 - class HandlebarsTemplate < Tilt::Template - def self.default_mime_type - 'application/javascript' - end - - def initialize_engine - HandlebarsRenderer.initialize_engine - end - - def prepare - @engine = renderer.choose_engine(data) - end - - def evaluate(scope, locals, &block) - source = @engine.render(scope, locals, &block) - renderer.compile(source) - end - - private - - def renderer - @renderer ||= HandlebarsRenderer.new(path: @file) - end - end - # Sprockets 4 class HandlebarsProcessor def self.instance @@ -115,7 +87,7 @@ def choose_engine(data) def compile(source) # remove trailing \n on file, for some reason the directives pipeline adds this - trim_source = source.chomp($INPUT_RECORD_SEPARATOR) + trim_source = source.chomp($/) # handle the case of multiple frameworks combined with ember # DEFER: use extension setup for ember diff --git a/test/handlebars_assets/hamlbars_test.rb b/test/handlebars_assets/hamlbars_test.rb index 2e8823b..c229f4d 100644 --- a/test/handlebars_assets/hamlbars_test.rb +++ b/test/handlebars_assets/hamlbars_test.rb @@ -26,9 +26,9 @@ def test_render_haml scope = make_scope root, file source = '%p This is {{handlebars}}' - template = HandlebarsAssets::HandlebarsTemplate.new(scope.pathname.to_s) { source } + rendered = HandlebarsAssets::HandlebarsProcessor.call(filename: scope.pathname.to_s, data: source) - assert_equal hbs_compiled('test_render', compile_haml(source)), template.render(scope, {}) + assert_equal hbs_compiled('test_render', compile_haml(source)), rendered end end end diff --git a/test/handlebars_assets/slimbars_test.rb b/test/handlebars_assets/slimbars_test.rb index cfb7ee1..5b70885 100644 --- a/test/handlebars_assets/slimbars_test.rb +++ b/test/handlebars_assets/slimbars_test.rb @@ -22,9 +22,9 @@ def test_render_slim scope = make_scope root, file source = 'p This is {{handlebars}}' - template = HandlebarsAssets::HandlebarsTemplate.new(scope.pathname.to_s) { source } + rendered = HandlebarsAssets::HandlebarsProcessor.call(filename: scope.pathname.to_s, data: source) - assert_equal hbs_compiled('test_render', compile_slim(source)), template.render(scope, {}) + assert_equal hbs_compiled('test_render', compile_slim(source)), rendered end end end diff --git a/test/handlebars_assets/tilt_handlebars_test.rb b/test/handlebars_assets/tilt_handlebars_test.rb deleted file mode 100644 index c659f2a..0000000 --- a/test/handlebars_assets/tilt_handlebars_test.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -require 'test_helper' -require_relative 'shared/adapter_tests' - -module HandlebarsAssets - class HandlebarsTemplateTest < Minitest::Test - include AdapterTests - - def teardown - HandlebarsAssets::Config.reset! - HandlebarsAssets::Handlebars.reset! - end - - def render_it(scope, source) - template = HandlebarsAssets::HandlebarsTemplate.new(scope.pathname.to_s) { source } - template.render(scope, {}) - end - end -end