slim-rails 3.4.0 → 3.5.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
2
  SHA256:
3
- metadata.gz: 9d672f03fbbe43effd0e993addabdd6ab61bbda0038edee278359483363caa98
4
- data.tar.gz: 98e150a881b76c14f4304728124366b44ce3d4335b9cb732cd6bbe6668c6011f
3
+ metadata.gz: 1b283190f2ca2912e814ef840f67711519392f8c339bc206d0b657d6c73161e8
4
+ data.tar.gz: b3b718e263251aa9105bdd41fda74b0c29059eb99d0fa89193a5be025385d3aa
5
5
  SHA512:
6
- metadata.gz: e4e81e2fe65f34fb318c40bf799dff4498010699a4721014f0b9c2e648c7e14ea6e19c1dd95c7e12aade2d82e7043cb1885560759874efd4e15f19a006109b55
7
- data.tar.gz: db4ed0ed081659fdd329345054bcdf1252437b69c8433aa045a1ede11211d0cda09e8754cca43a4a929226ba802637eccbc9fbb3988738761960d28ae8690a0d
6
+ metadata.gz: e59df33cbb85d0582050bf47800362f9f353230e2e6cd487921a33d36bc30ead174701be0b0681bea5a6a6b1699c58979e355509f2f23490b7fafc90993f5aaa
7
+ data.tar.gz: 0544655150a9a26c4a3d9f8dbd34b7d85b5ce8b6aa39f7e34bdcfc7d8459a5a163f126433e7cd40a823b966fd2699ed6db078397ff841bd38b815856fe2283fd
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## 3.5.0 (May 2022)
2
+
3
+ * Restored legacy templates for Rails < 7
4
+ * Updated Appraisals to supported Rails versions
5
+ * Replace Travis CI with Github Actions.
6
+
7
+ Thanks https://github.com/davidwessman (#180)
8
+
9
+
1
10
  ## 3.4.0 (March 2022)
2
11
 
3
12
  * Updated templates to Rails 7 style (thanks github.com/viktorianer) (#178)
data/README.md CHANGED
@@ -1,4 +1,4 @@
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)
1
+ # slim-rails [![Gem Version](https://img.shields.io/gem/v/slim-rails.svg)](http://rubygems.org/gems/slim-rails) [![Build Status](https://github.com/slim-template/slim-rails/actions/workflows/main.yml/badge.svg)](https://github.com/slim-template/slim-rails/actions/workflows/main.yml) [![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
@@ -1,15 +1,15 @@
1
- require 'rails/generators/erb/controller/controller_generator'
1
+ require "rails/generators/erb/controller/controller_generator"
2
2
 
3
3
  module Slim
4
4
  module Generators
5
5
  class ControllerGenerator < Erb::Generators::ControllerGenerator
6
- source_root File.expand_path(File.join('..', 'templates'), __FILE__)
6
+ source_root File.expand_path(File.join("..", "templates"), __FILE__)
7
7
 
8
8
  protected
9
+
9
10
  def handler
10
11
  :slim
11
12
  end
12
-
13
13
  end
14
14
  end
15
15
  end
@@ -1,11 +1,12 @@
1
- require 'rails/generators/erb/mailer/mailer_generator'
1
+ require "rails/generators/erb/mailer/mailer_generator"
2
2
 
3
3
  module Slim
4
4
  module Generators
5
5
  class MailerGenerator < Erb::Generators::MailerGenerator
6
- source_root File.expand_path(File.join('..', 'templates'), __FILE__)
6
+ source_root File.expand_path(File.join("..", "templates"), __FILE__)
7
7
 
8
8
  protected
9
+
9
10
  def format
10
11
  :text
11
12
  end
@@ -0,0 +1,14 @@
1
+ = form_for @<%= singular_table_name %> do |f|
2
+ - if @<%= singular_table_name %>.errors.any?
3
+ #error_explanation
4
+ h2 = "#{pluralize(@<%= singular_table_name %>.errors.count, "error")} prohibited this <%= singular_table_name %> from being saved:"
5
+ ul
6
+ - @<%= singular_table_name %>.errors.full_messages.each do |message|
7
+ li = message
8
+
9
+ <% attributes.each do |attribute| -%>
10
+ .field
11
+ = f.label :<%= attribute.name %>
12
+ = f.<%= attribute.field_type %> :<%= attribute.name %>
13
+ <% end -%>
14
+ .actions = f.submit
@@ -0,0 +1,7 @@
1
+ h1 Editing <%= singular_table_name %>
2
+
3
+ == render "form"
4
+
5
+ => link_to "Show", @<%= singular_table_name %>
6
+ '|
7
+ =< link_to "Back", <%= index_helper %>_path
@@ -0,0 +1,25 @@
1
+ h1 Listing <%= plural_table_name %>
2
+
3
+ table
4
+ thead
5
+ tr
6
+ <% attributes.each do |attribute| -%>
7
+ th <%= attribute.human_name %>
8
+ <% end -%>
9
+ th
10
+ th
11
+ th
12
+
13
+ tbody
14
+ - @<%= plural_table_name %>.each do |<%= singular_table_name %>|
15
+ tr
16
+ <% attributes.each do |attribute| -%>
17
+ td = <%= singular_table_name %>.<%= attribute.name %>
18
+ <% end -%>
19
+ td = link_to "Show", <%= singular_table_name %>
20
+ td = link_to "Edit", edit_<%= singular_table_name %>_path(<%= singular_table_name %>)
21
+ td = link_to "Destroy", <%= singular_table_name %>, data: {confirm: "Are you sure?"}, method: :delete
22
+
23
+ br
24
+
25
+ = link_to "New <%= human_name %>", new_<%= singular_table_name %>_path
@@ -0,0 +1,5 @@
1
+ h1 New <%= singular_table_name %>
2
+
3
+ == render "form"
4
+
5
+ = link_to "Back", <%= index_helper %>_path
@@ -0,0 +1,11 @@
1
+ p#notice = notice
2
+ <% attributes.each do |attribute| -%>
3
+
4
+ p
5
+ strong <%= attribute.human_name %>:
6
+ = @<%= singular_table_name %>.<%= attribute.name %>
7
+ <% end -%>
8
+
9
+ => link_to "Edit", edit_<%= singular_table_name %>_path(@<%= singular_table_name %>)
10
+ '|
11
+ =< link_to "Back", <%= index_helper %>_path
@@ -1,17 +1,23 @@
1
- require 'rails/generators/erb/scaffold/scaffold_generator'
1
+ require "rails/generators/erb/scaffold/scaffold_generator"
2
2
 
3
3
  module Slim
4
4
  module Generators
5
5
  class ScaffoldGenerator < Erb::Generators::ScaffoldGenerator # :nodoc:
6
- source_root File.expand_path(File.join('..', 'templates'), __FILE__)
6
+ if ::Rails::VERSION::MAJOR >= 7
7
+ source_root File.expand_path(File.join("..", "templates"), __FILE__)
8
+ else
9
+ source_root File.expand_path(File.join("..", "legacy_templates"), __FILE__)
10
+ end
7
11
 
8
12
  def copy_view_files
9
13
  available_views.each do |view|
10
14
  filename = filename_with_extensions view
11
- template "#{view}.html.slim", File.join('app', 'views', controller_file_path, filename)
15
+ template "#{view}.html.slim", File.join("app", "views", controller_file_path, filename)
12
16
  end
13
17
 
14
- template 'partial.html.slim', File.join('app/views', controller_file_path, "_#{singular_name}.html.slim")
18
+ if ::Rails::VERSION::MAJOR >= 7
19
+ template "partial.html.slim", File.join("app/views", controller_file_path, "_#{singular_name}.html.slim")
20
+ end
15
21
  end
16
22
 
17
23
  hook_for :form_builder, as: :scaffold
@@ -1,7 +1,7 @@
1
1
  = form_with(model: @<%= model_resource_name %>) do |form|
2
2
  - if @<%= singular_table_name %>.errors.any?
3
3
  div style="color: red"
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.each do |error|
7
7
  li = error.full_message
@@ -23,7 +23,7 @@ module Slim
23
23
  return unless app.assets
24
24
  return unless app.assets.respond_to?(:register_engine)
25
25
 
26
- app.assets.register_engine('.slim', Slim::Template)
26
+ app.assets.register_engine(".slim", Slim::Template)
27
27
  end
28
28
 
29
29
  def _register_engine(config)
@@ -31,11 +31,11 @@ module Slim
31
31
 
32
32
  config.assets.configure do |env|
33
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
34
+ env.register_mime_type "text/slim", extensions: [".slim", ".slim.html"] # , charset: :html
35
+ env.register_transformer "text/slim", "text/html", RegisterEngine::Transformer
36
36
  elsif env.respond_to?(:register_engine)
37
- args = ['.slim', Slim::Template]
38
- args << { silence_deprecation: true } if Sprockets::VERSION.start_with?('3')
37
+ args = [".slim", Slim::Template]
38
+ args << {silence_deprecation: true} if Sprockets::VERSION.start_with?("3")
39
39
  env.register_engine(*args)
40
40
  end
41
41
  end
@@ -1,5 +1,5 @@
1
1
  module Slim
2
2
  module Rails
3
- VERSION = '3.4.0'
3
+ VERSION = "3.5.0"
4
4
  end
5
5
  end
data/lib/slim-rails.rb CHANGED
@@ -1,35 +1,33 @@
1
- require 'slim-rails/version'
2
- require 'rails'
3
- require 'slim'
4
- require 'slim-rails/register_engine'
1
+ require "slim-rails/version"
2
+ require "rails"
3
+ require "slim"
4
+ require "slim-rails/register_engine"
5
5
 
6
6
  module Slim
7
7
  module Rails
8
8
  class Railtie < ::Rails::Railtie
9
9
  config.app_generators.template_engine :slim
10
10
 
11
- initializer 'slim_rails.configure_template_digestor' do |app|
11
+ initializer "slim_rails.configure_template_digestor" do |app|
12
12
  Slim::Rails::RegisterEngine.register_engine(app, config)
13
13
 
14
14
  ActiveSupport.on_load(:action_view) do
15
15
  ActiveSupport.on_load(:after_initialize) do
16
- begin
17
- if defined?(CacheDigests::DependencyTracker)
18
- # 'cache_digests' gem being used (overrides Rails 4 implementation)
19
- CacheDigests::DependencyTracker.register_tracker :slim, CacheDigests::DependencyTracker::ERBTracker
16
+ if defined?(CacheDigests::DependencyTracker)
17
+ # 'cache_digests' gem being used (overrides Rails 4 implementation)
18
+ CacheDigests::DependencyTracker.register_tracker :slim, CacheDigests::DependencyTracker::ERBTracker
20
19
 
21
- if ::Rails.env.development?
22
- # recalculate cache digest keys for each request
23
- CacheDigests::TemplateDigestor.cache = ActiveSupport::Cache::NullStore.new
24
- end
25
- elsif ::Rails.version.to_s >= '4.0'
26
- # will only apply if Rails 4, which includes 'action_view/dependency_tracker'
27
- require 'action_view/dependency_tracker'
28
- ActionView::DependencyTracker.register_tracker :slim, ActionView::DependencyTracker::ERBTracker
20
+ if ::Rails.env.development?
21
+ # recalculate cache digest keys for each request
22
+ CacheDigests::TemplateDigestor.cache = ActiveSupport::Cache::NullStore.new
29
23
  end
30
- rescue
31
- # likely this version of Rails doesn't support dependency tracking
24
+ elsif ::Rails.version.to_s >= "4.0"
25
+ # will only apply if Rails 4, which includes 'action_view/dependency_tracker'
26
+ require "action_view/dependency_tracker"
27
+ ActionView::DependencyTracker.register_tracker :slim, ActionView::DependencyTracker::ERBTracker
32
28
  end
29
+ rescue
30
+ # likely this version of Rails doesn't support dependency tracking
33
31
  end
34
32
  end
35
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slim-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.0
4
+ version: 3.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leonardo Almeida
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-03-15 00:00:00.000000000 Z
12
+ date: 2022-05-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack
@@ -157,6 +157,20 @@ dependencies:
157
157
  - - ">="
158
158
  - !ruby/object:Gem::Version
159
159
  version: '0'
160
+ - !ruby/object:Gem::Dependency
161
+ name: standardrb
162
+ requirement: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ type: :development
168
+ prerelease: false
169
+ version_requirements: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
160
174
  description: Provides the generator settings required for Rails to use Slim
161
175
  email:
162
176
  - lalmeida08@gmail.com
@@ -175,6 +189,11 @@ files:
175
189
  - lib/generators/slim/mailer/templates/layout.text.slim
176
190
  - lib/generators/slim/mailer/templates/view.html.slim
177
191
  - lib/generators/slim/mailer/templates/view.text.slim
192
+ - lib/generators/slim/scaffold/legacy_templates/_form.html.slim.tt
193
+ - lib/generators/slim/scaffold/legacy_templates/edit.html.slim.tt
194
+ - lib/generators/slim/scaffold/legacy_templates/index.html.slim.tt
195
+ - lib/generators/slim/scaffold/legacy_templates/new.html.slim.tt
196
+ - lib/generators/slim/scaffold/legacy_templates/show.html.slim.tt
178
197
  - lib/generators/slim/scaffold/scaffold_generator.rb
179
198
  - lib/generators/slim/scaffold/templates/_form.html.slim.tt
180
199
  - lib/generators/slim/scaffold/templates/edit.html.slim.tt