slim-rails 3.1.1 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 730249022955562dd8f32bc57713909e0e34e84c
4
- data.tar.gz: 4ac7a9296a96b94e8106df5d1bef4423dfbe2e7b
2
+ SHA256:
3
+ metadata.gz: 4c09a72b540b1eeeb00a3fa4a3a35fa6cb34d064104a9a7155f14ecee5e7e39d
4
+ data.tar.gz: 2210937c961529642a2fc5ff485dd13de10f46694259d74d0521593182e095c0
5
5
  SHA512:
6
- metadata.gz: 20768a544ba036ed3351a9acbcabe7b6fcd18cf7ec50e5f4383f476d42b957b613f96c800e0e1c43d9782f79e228c80127f2b2b6d8842b3e26d8b1b9e34feb6f
7
- data.tar.gz: d0b3b687b462254b194daaa07ff77c17ce1104007f74d33ec71bb7d9a30a64958cf3823eaae7c61ca4e4ee1659a5f8ce0782378f5b628196d286c0da3b88adc8
6
+ metadata.gz: ef5677b920c4a940df436fbad90dbf8e6e97b074f4c6b498a6b9f2b323588280ba5fc6f708dddf4459cb5cb609ea4af0fad03350fd1a013b3bb25b55fa468638
7
+ data.tar.gz: f77d561a26be9f8967ebd2e7ead43e01c9b9219c1445d88c9c09ca0f271326ca30ab920cb202ecf3cdc90f21edd5d51089f60c2d4d9c739d05ebcf45d186846e
data/.travis.yml CHANGED
@@ -1,19 +1,45 @@
1
+ dist: focal
2
+
3
+ os: linux
4
+
1
5
  language: ruby
6
+
7
+ cache:
8
+ bundler: true
9
+
2
10
  before_install:
3
- - gem install bundler
11
+ - gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
12
+ - gem install bundler -v '< 2'
13
+
4
14
  rvm:
5
15
  - ruby-head
6
- - 2.2.2
7
- - 2.1
8
- - 2.0
16
+ - 3.0
17
+ - 2.7
18
+ - 2.6
19
+
9
20
  gemfile:
10
- - gemfiles/rails_3.gemfile
11
- - gemfiles/rails_4.gemfile
12
- - gemfiles/rails_4.1.gemfile
13
- - gemfiles/rails_4.2.gemfile
14
- matrix:
21
+ - gemfiles/rails_edge.gemfile
22
+ - gemfiles/rails_6.1.gemfile
23
+ - gemfiles/rails_6.0.gemfile
24
+ - gemfiles/rails_5.2.gemfile
25
+ - gemfiles/rails_5.1.gemfile
26
+ - gemfiles/rails_5.0.gemfile
27
+
28
+ jobs:
15
29
  allow_failures:
16
30
  - rvm: ruby-head
31
+ - gemfile: gemfiles/rails_edge.gemfile
32
+
33
+ exclude:
34
+ - rvm: 3.0
35
+ gemfile: gemfiles/rails_5.2.gemfile
36
+ - rvm: 3.0
37
+ gemfile: gemfiles/rails_5.1.gemfile
38
+ - rvm: 3.0
39
+ gemfile: gemfiles/rails_5.0.gemfile
40
+
41
+ fast_finish: true
42
+
17
43
  addons:
18
44
  code_climate:
19
45
  repo_token: 294f0ec8183176c0259b75eb21b38414508616985a7b39fc48fec9dfcf40a52e
data/Appraisals CHANGED
@@ -1,21 +1,25 @@
1
- appraise "rails-3" do
2
- gem "rails", "~> 3.2"
3
- gem 'minitest'
4
- gem 'test-unit', '~> 3.0'
1
+ appraise "rails-5.0" do
2
+ gem "rails", "~> 5.0.0"
3
+ gem "sprockets", "~> 3.7"
5
4
  end
6
5
 
7
- appraise "rails-4" do
8
- gem "rails", "~> 4.0.0"
6
+ appraise "rails-5.1" do
7
+ gem "rails", "~> 5.1.0"
8
+ gem "sprockets", "~> 3.7"
9
9
  end
10
10
 
11
- appraise "rails-4.1" do
12
- gem "rails", "~> 4.1.0"
11
+ appraise "rails-5.2" do
12
+ gem "rails", "~> 5.2.0"
13
13
  end
14
14
 
15
- appraise "rails-4.2" do
16
- gem "rails", "~> 4.2.0"
15
+ appraise "rails-6.0" do
16
+ gem "rails", "~> 6.0.3"
17
17
  end
18
18
 
19
- appraise "rails-5" do
20
- gem "rails", "~> 5.0.0"
19
+ appraise "rails-6.1" do
20
+ gem "rails", "~> 6.1.3"
21
+ end
22
+
23
+ appraise "rails-edge" do
24
+ gem "rails", github: 'rails/rails'
21
25
  end
data/CHANGELOG.md ADDED
@@ -0,0 +1,42 @@
1
+ ## 3.3.0 (July 19, 2021)
2
+
3
+ * Enabled asset helpers in precompiled templates (#135)
4
+ * Tested with Rails 6.0, 6.1 and Ruby 3.0
5
+ * Improved CI and tests with Sprockets 4
6
+
7
+
8
+ ## 3.2.0 (October 7, 2018)
9
+
10
+ * Support for Slim 4
11
+
12
+
13
+ ## 3.1.3 (April 3, 2017)
14
+
15
+ * Improved compatibility with Sprockets 4
16
+
17
+
18
+ ## 3.1.2 (February 3, 2017)
19
+
20
+ * Tested compatibility with Ruby 2.4
21
+ * Updated CI specs
22
+
23
+
24
+ ## 3.1.1 (August 29, 2016)
25
+
26
+ * Initial support for Sprockets 4
27
+
28
+
29
+ ## 3.1.0 (June 7, 2016)
30
+
31
+ * Support for Rails 5
32
+ * MailerGenerator
33
+
34
+
35
+ ## 3.0.2 (May 21, 2016)
36
+
37
+ * Code cleanup and refactoring
38
+
39
+
40
+ ## 3.0.1 (December 26, 2014)
41
+
42
+ * Support for Rails 4.2
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # slim-rails [![Build Status](https://travis-ci.org/slim-template/slim-rails.png?branch=master)](https://travis-ci.org/slim-template/slim-rails) [![Code Climate](https://codeclimate.com/github/slim-template/slim-rails/badges/gpa.svg)](https://codeclimate.com/github/slim-template/slim-rails)
1
+ # slim-rails [![Gem Version](https://img.shields.io/gem/v/slim-rails.svg)](http://rubygems.org/gems/slim-rails) [![Build Status](https://travis-ci.org/slim-template/slim-rails.svg?branch=master)](https://travis-ci.org/slim-template/slim-rails) [![Code Climate](https://codeclimate.com/github/slim-template/slim-rails/badges/gpa.svg)](https://codeclimate.com/github/slim-template/slim-rails)
2
2
 
3
3
  slim-rails provides Slim generators for Rails 3+. It was based on
4
4
  [haml-rails](http://github.com/indirect/haml-rails) and it does basically the
@@ -18,6 +18,8 @@ gem "slim-rails"
18
18
 
19
19
  And that's it.
20
20
 
21
+ If you have existing `.erb` templates, check out [our guide](https://github.com/slim-template/slim/wiki/Template-Converters-ERB-to-SLIM) on how to achieve this.
22
+
21
23
  From the version 0.2.0, there is no need to include gem "slim" in your Gemfile.
22
24
 
23
- Every time you generate a controller or scaffold, you'll get Slim templates.
25
+ Every time you generate a controller or scaffold, you'll get Slim templates.
@@ -3,5 +3,6 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "rails", "~> 5.0.0"
6
+ gem "sprockets", "~> 3.7"
6
7
 
7
- gemspec :path => "../"
8
+ gemspec path: "../"
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 5.1.0"
6
+ gem "sprockets", "~> 3.7"
7
+
8
+ gemspec path: "../"
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "rails", "~> 4.1.0"
5
+ gem "rails", "~> 5.2.0"
6
6
 
7
- gemspec :path => "../"
7
+ gemspec path: "../"
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "rails", "~> 4.2.0"
5
+ gem "rails", "~> 6.0.3"
6
6
 
7
- gemspec :path => "../"
7
+ gemspec path: "../"
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "rails", "~> 4.0.0"
5
+ gem "rails", "~> 6.1.3"
6
6
 
7
- gemspec :path => "../"
7
+ gemspec path: "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", github: "rails/rails"
6
+
7
+ gemspec path: "../"
@@ -1,2 +1,2 @@
1
1
  h1 <%= class_name %>#<%= @action %>
2
- p = @greeting + ", find me in <%= @path %>"
2
+ p = "#{@greeting}, find me in <%= @path %>"
@@ -1,3 +1,3 @@
1
1
  ' <%= class_name %>#<%= @action %>
2
2
  = "\r\n" * 2
3
- ' #{@greeting + ", find me in <%= @path %>"}
3
+ ' #{@greeting}, find me in <%= @path %>
@@ -1,7 +1,7 @@
1
1
  = form_for @<%= singular_table_name %> do |f|
2
2
  - if @<%= singular_table_name %>.errors.any?
3
3
  #error_explanation
4
- h2 = "#{pluralize(@<%= singular_table_name %>.errors.count, "error")} prohibited this <%= singular_table_name %> from being saved:"
4
+ h2 = "#{pluralize(@<%= singular_table_name %>.errors.count, 'error')} prohibited this <%= singular_table_name %> from being saved:"
5
5
  ul
6
6
  - @<%= singular_table_name %>.errors.full_messages.each do |message|
7
7
  li = message
@@ -2,7 +2,6 @@ h1 Editing <%= singular_table_name %>
2
2
 
3
3
  == render 'form'
4
4
 
5
- = link_to 'Show', @<%= singular_table_name %>
5
+ => link_to 'Show', @<%= singular_table_name %>
6
6
  '|
7
- = link_to 'Back', <%= index_helper %>_path
8
-
7
+ =< link_to 'Back', <%= index_helper %>_path
@@ -1,11 +1,11 @@
1
1
  p#notice = notice
2
-
3
2
  <% attributes.each do |attribute| -%>
3
+
4
4
  p
5
5
  strong <%= attribute.human_name %>:
6
6
  = @<%= singular_table_name %>.<%= attribute.name %>
7
7
  <% end -%>
8
8
 
9
- = link_to 'Edit', edit_<%= singular_table_name %>_path(@<%= singular_table_name %>)
9
+ => link_to 'Edit', edit_<%= singular_table_name %>_path(@<%= singular_table_name %>)
10
10
  '|
11
- = link_to 'Back', <%= index_helper %>_path
11
+ =< link_to 'Back', <%= index_helper %>_path
@@ -3,40 +3,41 @@ module Slim
3
3
  module RegisterEngine
4
4
  class Transformer
5
5
  def self.call(input)
6
- Slim::Template.new(input[:name]) { input[:data] }.render(nil)
6
+ context = input[:environment].context_class.new(input)
7
+ Slim::Template.new(input[:name]) { input[:data] }.render(context)
7
8
  end
8
9
  end
9
10
 
10
- def self.register_engine(app, config)
11
- if ::Rails::VERSION::MAJOR == 3
12
- _register_engine3(app)
13
- else
14
- _register_engine(config)
11
+ class << self
12
+ def register_engine(app, config)
13
+ if ::Rails::VERSION::MAJOR == 3
14
+ _register_engine3(app)
15
+ else
16
+ _register_engine(config)
17
+ end
15
18
  end
16
- end
17
-
18
- private
19
19
 
20
- def self._register_engine3(app)
21
- return unless app.assets
22
- return unless app.assets.respond_to?(:register_engine)
20
+ private
23
21
 
24
- app.assets.register_engine('.slim', Slim::Template)
25
- end
22
+ def _register_engine3(app)
23
+ return unless app.assets
24
+ return unless app.assets.respond_to?(:register_engine)
26
25
 
27
- def self._register_engine(config)
28
- return unless config.respond_to?(:assets)
26
+ app.assets.register_engine('.slim', Slim::Template)
27
+ end
29
28
 
30
- config.assets.configure do |env|
31
- if env.respond_to?(:register_transformer)
32
- env.register_mime_type 'text/slim', extensions: ['.slim', '.slim.html']#, charset: :html
33
- env.register_preprocessor 'text/slim', 'text/html', RegisterEngine::Transformer
34
- end
29
+ def _register_engine(config)
30
+ return unless config.respond_to?(:assets)
35
31
 
36
- if env.respond_to?(:register_engine)
37
- args = ['.slim', Slim::Template]
38
- args << { silence_deprecation: true } if Sprockets::VERSION.start_with?("3")
39
- env.register_engine(*args)
32
+ config.assets.configure do |env|
33
+ if env.respond_to?(:register_transformer) && Sprockets::VERSION.to_i > 3
34
+ env.register_mime_type 'text/slim', extensions: ['.slim', '.slim.html']#, charset: :html
35
+ env.register_transformer 'text/slim', 'text/html', RegisterEngine::Transformer
36
+ elsif env.respond_to?(:register_engine)
37
+ args = ['.slim', Slim::Template]
38
+ args << { silence_deprecation: true } if Sprockets::VERSION.start_with?('3')
39
+ env.register_engine(*args)
40
+ end
40
41
  end
41
42
  end
42
43
  end
@@ -1,5 +1,5 @@
1
1
  module Slim
2
2
  module Rails
3
- VERSION = "3.1.1"
3
+ VERSION = '3.3.0'
4
4
  end
5
5
  end
data/slim-rails.gemspec CHANGED
@@ -6,11 +6,11 @@ require 'slim-rails/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'slim-rails'
8
8
  spec.version = Slim::Rails::VERSION
9
- spec.authors = ["Leonardo Almeida"]
10
- spec.email = ["lalmeida08@gmail.com"]
9
+ spec.authors = ["Leonardo Almeida", "Janusz Mordarski"]
10
+ spec.email = ["lalmeida08@gmail.com", "janusz.m@gmail.com"]
11
11
 
12
- spec.summary = 'Slim templates generator for Rails 3+'
13
- spec.description = 'Provides the generator settings required for Rails 3+ to use Slim'
12
+ spec.summary = 'Slim templates generator for Rails'
13
+ spec.description = 'Provides the generator settings required for Rails to use Slim'
14
14
  spec.homepage = 'https://github.com/slim-template/slim-rails'
15
15
  spec.license = 'MIT'
16
16
 
@@ -23,9 +23,10 @@ Gem::Specification.new do |spec|
23
23
 
24
24
  spec.add_runtime_dependency 'actionpack', ['>= 3.1']
25
25
  spec.add_runtime_dependency 'railties', ['>= 3.1']
26
- spec.add_runtime_dependency 'slim', ['~> 3.0']
26
+ spec.add_runtime_dependency 'slim', ['>= 3.0', '< 5.0']
27
27
 
28
28
  spec.add_development_dependency 'sprockets-rails'
29
+ spec.add_development_dependency 'slim_lint', '~> 0.21.0'
29
30
  spec.add_development_dependency 'rocco'
30
31
  spec.add_development_dependency 'redcarpet'
31
32
  spec.add_development_dependency 'awesome_print'
@@ -2,6 +2,8 @@ require 'test_helper'
2
2
  require 'lib/generators/slim/testing_helper'
3
3
 
4
4
  class Slim::Generators::ControllerGeneratorTest < Rails::Generators::TestCase
5
+ include SlimLintHelpers
6
+
5
7
  destination File.join(Rails.root)
6
8
  tests Rails::Generators::ControllerGenerator
7
9
  arguments %w(Account foo bar --template-engine slim)
@@ -14,4 +16,10 @@ class Slim::Generators::ControllerGeneratorTest < Rails::Generators::TestCase
14
16
  assert_file File.join("app", "views", "account", "foo.html.slim"), %r(app/views/account/foo\.html\.slim)
15
17
  assert_file File.join("app", "views", "account", "bar.html.slim"), %r(app/views/account/bar\.html\.slim)
16
18
  end
19
+
20
+ test "should generate SlimLint valid templates" do
21
+ run_generator
22
+ templates = Dir[File.join(Rails.root, 'app', 'views', '**', '*.slim')]
23
+ assert_empty lint(templates)
24
+ end
17
25
  end
@@ -2,6 +2,8 @@ require 'test_helper'
2
2
  require 'lib/generators/slim/testing_helper'
3
3
 
4
4
  class Slim::Generators::MailerGeneratorTest < Rails::Generators::TestCase
5
+ include SlimLintHelpers
6
+
5
7
  destination File.join(Rails.root)
6
8
  tests Rails::Generators::MailerGenerator
7
9
  arguments %w(notifier foo bar --template-engine slim)
@@ -12,36 +14,65 @@ class Slim::Generators::MailerGeneratorTest < Rails::Generators::TestCase
12
14
  test "should invoke template engine" do
13
15
  run_generator
14
16
 
15
- if ::Rails.version.to_s >= '4.2'
17
+ rails_version = ::Rails.version.to_s
16
18
 
17
- assert_file "app/views/layouts/mailer.text.slim" do |view|
18
- assert_match(/\= yield/, view)
19
+ if rails_version >= '5.0'
20
+ assert_file "app/views/notifier_mailer/foo.html.slim" do |view|
21
+ assert_match %r(app/views/notifier_mailer/foo\.html\.slim), view
22
+ assert_match(/\#\{@greeting/, view)
19
23
  end
20
24
 
21
- assert_file "app/views/layouts/mailer.html.slim" do |view|
22
- assert_match(/\= yield/, view)
25
+ assert_file "app/views/notifier_mailer/bar.html.slim" do |view|
26
+ assert_match %r(app/views/notifier_mailer/bar\.html\.slim), view
27
+ assert_match(/\#\{@greeting/, view)
23
28
  end
24
29
 
25
- assert_file "app/views/notifier/foo.html.slim" do |view|
26
- assert_match %r(app/views/notifier/foo\.html\.slim), view
27
- assert_match(/\= @greeting/, view)
30
+ assert_file "app/views/notifier_mailer/foo.text.slim" do |view|
31
+ assert_match %r(app/views/notifier_mailer/foo\.text\.slim), view
32
+ assert_match(/@greeting/, view)
28
33
  end
29
34
 
30
- assert_file "app/views/notifier/bar.html.slim" do |view|
31
- assert_match %r(app/views/notifier/bar\.html\.slim), view
32
- assert_match(/\= @greeting/, view)
35
+ assert_file "app/views/notifier_mailer/bar.text.slim" do |view|
36
+ assert_match %r(app/views/notifier_mailer/bar\.text\.slim), view
37
+ assert_match(/@greeting/, view)
33
38
  end
39
+ else
40
+ if rails_version >= '4.2'
41
+ assert_file "app/views/layouts/mailer.text.slim" do |view|
42
+ assert_match(/\= yield/, view)
43
+ end
34
44
 
35
- end
45
+ assert_file "app/views/layouts/mailer.html.slim" do |view|
46
+ assert_match(/\= yield/, view)
47
+ end
36
48
 
37
- assert_file "app/views/notifier/foo.text.slim" do |view|
38
- assert_match %r(app/views/notifier/foo\.text\.slim), view
39
- assert_match(/@greeting/, view)
40
- end
49
+ assert_file "app/views/notifier/foo.html.slim" do |view|
50
+ assert_match %r(app/views/notifier/foo\.html\.slim), view
51
+ assert_match(/\#\{@greeting/, view)
52
+ end
53
+
54
+ assert_file "app/views/notifier/bar.html.slim" do |view|
55
+ assert_match %r(app/views/notifier/bar\.html\.slim), view
56
+ assert_match(/\#\{@greeting/, view)
57
+ end
58
+
59
+ end
41
60
 
42
- assert_file "app/views/notifier/bar.text.slim" do |view|
43
- assert_match %r(app/views/notifier/bar\.text\.slim), view
44
- assert_match(/@greeting/, view)
61
+ assert_file "app/views/notifier/foo.text.slim" do |view|
62
+ assert_match %r(app/views/notifier/foo\.text\.slim), view
63
+ assert_match(/@greeting/, view)
64
+ end
65
+
66
+ assert_file "app/views/notifier/bar.text.slim" do |view|
67
+ assert_match %r(app/views/notifier/bar\.text\.slim), view
68
+ assert_match(/@greeting/, view)
69
+ end
45
70
  end
46
71
  end
72
+
73
+ test "should generate SlimLint valid templates" do
74
+ run_generator
75
+ templates = Dir[File.join(Rails.root, 'app', 'views', '**', '*.slim')]
76
+ assert_empty lint(templates)
77
+ end
47
78
  end
@@ -2,6 +2,8 @@ require 'test_helper'
2
2
  require 'lib/generators/slim/testing_helper'
3
3
 
4
4
  class Slim::Generators::ScaffoldGeneratorTest < Rails::Generators::TestCase
5
+ include SlimLintHelpers
6
+
5
7
  destination File.join(Rails.root)
6
8
  tests Rails::Generators::ScaffoldGenerator
7
9
  arguments %w(product_line title:string price:integer --template-engine slim --orm active-record)
@@ -23,4 +25,10 @@ class Slim::Generators::ScaffoldGeneratorTest < Rails::Generators::TestCase
23
25
  assert_no_file File.join "app", "views", "product_lines"
24
26
  assert_no_file File.join "app", "views", "layouts", "product_lines.html.slim"
25
27
  end
28
+
29
+ test "should generate SlimLint valid templates" do
30
+ run_generator
31
+ templates = Dir[File.join(Rails.root, 'app', 'views', '**', '*.slim')]
32
+ assert_empty lint(templates)
33
+ end
26
34
  end
@@ -1 +1,11 @@
1
+ require 'slim_lint'
2
+
3
+ module SlimLintHelpers
4
+ EXCLUDED_LINTERS = %w[LineLength]
5
+
6
+ def lint(templates)
7
+ SlimLint::Runner.new.run(files: templates, excluded_linters: EXCLUDED_LINTERS).lints.map(&:message)
8
+ end
9
+ end
10
+
1
11
  require_generators slim: ['scaffold', 'controller', 'mailer']
@@ -1,9 +1,14 @@
1
+ require 'sprockets'
1
2
  require 'test_helper'
2
3
  require 'tmpdir'
3
4
 
4
5
  class Slim::Rails::AssetsTest < ActiveSupport::TestCase
5
6
  def with_app(use_sprockets, code)
6
7
  Dir.mktmpdir do |dir|
8
+ manifest_path = File.join(dir, 'app', 'assets', 'config', 'manifest.js')
9
+ FileUtils.mkdir_p(File.dirname(manifest_path))
10
+ File.write(manifest_path, '//= link_tree ../html .slim')
11
+
7
12
  app_path = File.join(dir, 'app.rb')
8
13
  File.write(app_path, <<-APP)
9
14
  require 'rails'
@@ -11,22 +16,57 @@ class Slim::Rails::AssetsTest < ActiveSupport::TestCase
11
16
  require 'slim-rails'
12
17
  class DummyApp < ::Rails::Application
13
18
  config.root = #{dir.inspect}
14
- config.assets.enabled = true
19
+ config.assets.enabled = true if #{use_sprockets}
20
+ config.eager_load = false
15
21
  end
16
22
  DummyApp.initialize!
17
23
  #{code}
18
24
  APP
19
25
 
26
+ if use_sprockets && Sprockets::VERSION.to_i >= 4
27
+ manifest_path = File.join(dir, 'app', 'assets', 'config', 'manifest.js')
28
+ FileUtils.mkdir_p(File.dirname(manifest_path))
29
+ File.write(manifest_path, '')
30
+ end
31
+
20
32
  asset_path = File.join(dir, 'app', 'assets', 'html', 'test.slim')
21
33
  FileUtils.mkdir_p(File.dirname(asset_path))
22
34
  File.write(asset_path, ".test\n | hi")
23
35
 
36
+ asset_path = File.join(dir, 'app', 'assets', 'html', 'test_helpers.slim')
37
+ File.write(asset_path, '= logical_path')
38
+
24
39
  `BUNDLE_GEMFILE=#{ENV['BUNDLE_GEMFILE']} bundle exec ruby #{app_path}`
25
40
  end
26
41
  end
27
42
 
28
- test 'compile slim view' do
29
- assert_equal 'ok', with_app(false, 'print DummyApp.assets || "ok"')
30
- assert_equal '<div class="test">hi</div>', with_app(true, 'print DummyApp.assets["test.slim"].to_s')
43
+ test "should work without Sprockets" do
44
+ assert_equal '', with_app(false, 'DummyApp.assets')
45
+ end
46
+
47
+ test "should return HTML version when passing 'text/html' content type" do
48
+ assert_equal '<div class="test">hi</div>', with_app(true, 'print DummyApp.assets["test", accept: "text/html"]')
49
+ end
50
+
51
+ if Sprockets::VERSION.to_i < 4
52
+ test "should return HTML version when passing '.slim' extension" do
53
+ assert_equal '<div class="test">hi</div>', with_app(true, 'print DummyApp.assets["test.slim"]')
54
+ end
55
+ end
56
+
57
+ if Sprockets::VERSION.to_i >= 3
58
+ test "should return HTML version when passing '.html' extension" do
59
+ assert_equal '<div class="test">hi</div>', with_app(true, 'print DummyApp.assets["test.html"]')
60
+ end
61
+ end
62
+
63
+ if Sprockets::VERSION.to_i >= 4
64
+ test "should return Slim version when passing '.slim' extension" do
65
+ assert_equal ".test\n | hi", with_app(true, 'print DummyApp.assets["test.slim"]')
66
+ end
67
+ end
68
+
69
+ test "should work with asset helpers" do
70
+ assert_equal 'test_helpers', with_app(true, 'print DummyApp.assets["test_helpers", accept: "text/html"]')
31
71
  end
32
72
  end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slim-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.1
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leonardo Almeida
8
- autorequire:
8
+ - Janusz Mordarski
9
+ autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2016-08-29 00:00:00.000000000 Z
12
+ date: 2021-07-19 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: actionpack
@@ -42,16 +43,22 @@ dependencies:
42
43
  name: slim
43
44
  requirement: !ruby/object:Gem::Requirement
44
45
  requirements:
45
- - - "~>"
46
+ - - ">="
46
47
  - !ruby/object:Gem::Version
47
48
  version: '3.0'
49
+ - - "<"
50
+ - !ruby/object:Gem::Version
51
+ version: '5.0'
48
52
  type: :runtime
49
53
  prerelease: false
50
54
  version_requirements: !ruby/object:Gem::Requirement
51
55
  requirements:
52
- - - "~>"
56
+ - - ">="
53
57
  - !ruby/object:Gem::Version
54
58
  version: '3.0'
59
+ - - "<"
60
+ - !ruby/object:Gem::Version
61
+ version: '5.0'
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: sprockets-rails
57
64
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +73,20 @@ dependencies:
66
73
  - - ">="
67
74
  - !ruby/object:Gem::Version
68
75
  version: '0'
76
+ - !ruby/object:Gem::Dependency
77
+ name: slim_lint
78
+ requirement: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.21.0
83
+ type: :development
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.21.0
69
90
  - !ruby/object:Gem::Dependency
70
91
  name: rocco
71
92
  requirement: !ruby/object:Gem::Requirement
@@ -136,9 +157,10 @@ dependencies:
136
157
  - - ">="
137
158
  - !ruby/object:Gem::Version
138
159
  version: '0'
139
- description: Provides the generator settings required for Rails 3+ to use Slim
160
+ description: Provides the generator settings required for Rails to use Slim
140
161
  email:
141
162
  - lalmeida08@gmail.com
163
+ - janusz.m@gmail.com
142
164
  executables: []
143
165
  extensions: []
144
166
  extra_rdoc_files: []
@@ -146,15 +168,17 @@ files:
146
168
  - ".gitignore"
147
169
  - ".travis.yml"
148
170
  - Appraisals
171
+ - CHANGELOG.md
149
172
  - Gemfile
150
173
  - LICENSE
151
174
  - README.md
152
175
  - Rakefile
153
- - gemfiles/rails_3.gemfile
154
- - gemfiles/rails_4.1.gemfile
155
- - gemfiles/rails_4.2.gemfile
156
- - gemfiles/rails_4.gemfile
157
- - gemfiles/rails_5.gemfile
176
+ - gemfiles/rails_5.0.gemfile
177
+ - gemfiles/rails_5.1.gemfile
178
+ - gemfiles/rails_5.2.gemfile
179
+ - gemfiles/rails_6.0.gemfile
180
+ - gemfiles/rails_6.1.gemfile
181
+ - gemfiles/rails_edge.gemfile
158
182
  - lib/generators/slim/controller/controller_generator.rb
159
183
  - lib/generators/slim/controller/templates/view.html.slim
160
184
  - lib/generators/slim/mailer/mailer_generator.rb
@@ -183,7 +207,7 @@ homepage: https://github.com/slim-template/slim-rails
183
207
  licenses:
184
208
  - MIT
185
209
  metadata: {}
186
- post_install_message:
210
+ post_install_message:
187
211
  rdoc_options: []
188
212
  require_paths:
189
213
  - lib
@@ -198,11 +222,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
198
222
  - !ruby/object:Gem::Version
199
223
  version: '0'
200
224
  requirements: []
201
- rubyforge_project:
202
- rubygems_version: 2.6.2
203
- signing_key:
225
+ rubygems_version: 3.1.6
226
+ signing_key:
204
227
  specification_version: 4
205
- summary: Slim templates generator for Rails 3+
228
+ summary: Slim templates generator for Rails
206
229
  test_files:
207
230
  - test/fixtures/routes.rb
208
231
  - test/lib/generators/slim/controller_generator_test.rb
@@ -1,9 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 3.2"
6
- gem "minitest"
7
- gem "test-unit", "~> 3.0"
8
-
9
- gemspec :path => "../"