Skip to content

Commit

Permalink
feat: remove tilt and old support files
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexRiedler committed Dec 16, 2024
1 parent 36b3b80 commit f878eae
Show file tree
Hide file tree
Showing 16 changed files with 35 additions and 139 deletions.
4 changes: 0 additions & 4 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 0 additions & 10 deletions gemfiles/rails_4_1.gemfile

This file was deleted.

10 changes: 0 additions & 10 deletions gemfiles/rails_4_2.gemfile

This file was deleted.

10 changes: 0 additions & 10 deletions gemfiles/rails_5.gemfile

This file was deleted.

9 changes: 0 additions & 9 deletions gemfiles/sprockets_2.gemfile

This file was deleted.

9 changes: 0 additions & 9 deletions gemfiles/sprockets_3.gemfile

This file was deleted.

15 changes: 10 additions & 5 deletions gemfiles/sprockets_4_0.gemfile
Original file line number Diff line number Diff line change
@@ -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: "../"
15 changes: 10 additions & 5 deletions gemfiles/sprockets_4_1.gemfile
Original file line number Diff line number Diff line change
@@ -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: "../"
15 changes: 10 additions & 5 deletions gemfiles/sprockets_4_2.gemfile
Original file line number Diff line number Diff line change
@@ -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: "../"
9 changes: 0 additions & 9 deletions gemfiles/tilt_1.gemfile

This file was deleted.

9 changes: 0 additions & 9 deletions gemfiles/tilt_2.gemfile

This file was deleted.

1 change: 0 additions & 1 deletion handlebars_assets.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
30 changes: 1 addition & 29 deletions lib/handlebars_assets/handlebars_template.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require 'English'
require 'tilt'
require 'json'

module HandlebarsAssets
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/handlebars_assets/hamlbars_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions test/handlebars_assets/slimbars_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
20 changes: 0 additions & 20 deletions test/handlebars_assets/tilt_handlebars_test.rb

This file was deleted.

0 comments on commit f878eae

Please sign in to comment.