slim-rails 3.2.0 → 3.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +21 -0
  3. data/README.md +3 -1
  4. data/lib/generators/slim/controller/controller_generator.rb +3 -3
  5. data/lib/generators/slim/mailer/mailer_generator.rb +3 -2
  6. data/lib/generators/slim/mailer/templates/view.html.slim +1 -1
  7. data/lib/generators/slim/mailer/templates/view.text.slim +1 -1
  8. data/lib/generators/slim/scaffold/{templates/_form.html.slim → legacy_templates/_form.html.slim.tt} +0 -0
  9. data/lib/generators/slim/scaffold/legacy_templates/edit.html.slim.tt +7 -0
  10. data/lib/generators/slim/scaffold/{templates/index.html.slim → legacy_templates/index.html.slim.tt} +4 -4
  11. data/lib/generators/slim/scaffold/legacy_templates/new.html.slim.tt +5 -0
  12. data/lib/generators/slim/scaffold/{templates/show.html.slim → legacy_templates/show.html.slim.tt} +3 -3
  13. data/lib/generators/slim/scaffold/scaffold_generator.rb +14 -5
  14. data/lib/generators/slim/scaffold/templates/_form.html.slim.tt +28 -0
  15. data/lib/generators/slim/scaffold/templates/edit.html.slim.tt +10 -0
  16. data/lib/generators/slim/scaffold/templates/index.html.slim.tt +11 -0
  17. data/lib/generators/slim/scaffold/templates/new.html.slim.tt +8 -0
  18. data/lib/generators/slim/scaffold/templates/partial.html.slim.tt +14 -0
  19. data/lib/generators/slim/scaffold/templates/show.html.slim.tt +10 -0
  20. data/lib/slim-rails/register_engine.rb +7 -6
  21. data/lib/slim-rails/version.rb +1 -1
  22. data/lib/slim-rails.rb +17 -19
  23. metadata +50 -42
  24. data/.gitignore +0 -20
  25. data/.travis.yml +0 -50
  26. data/Appraisals +0 -29
  27. data/Gemfile +0 -3
  28. data/Rakefile +0 -12
  29. data/gemfiles/rails_3.gemfile +0 -9
  30. data/gemfiles/rails_4.1.gemfile +0 -7
  31. data/gemfiles/rails_4.2.gemfile +0 -7
  32. data/gemfiles/rails_4.gemfile +0 -7
  33. data/gemfiles/rails_5.1.gemfile +0 -7
  34. data/gemfiles/rails_5.2.gemfile +0 -7
  35. data/gemfiles/rails_5.gemfile +0 -7
  36. data/lib/generators/slim/scaffold/templates/edit.html.slim +0 -8
  37. data/lib/generators/slim/scaffold/templates/new.html.slim +0 -5
  38. data/slim-rails.gemspec +0 -34
  39. data/test/fixtures/routes.rb +0 -58
  40. data/test/lib/generators/slim/controller_generator_test.rb +0 -17
  41. data/test/lib/generators/slim/mailer_generator_test.rb +0 -70
  42. data/test/lib/generators/slim/scaffold_generator_test.rb +0 -26
  43. data/test/lib/generators/slim/testing_helper.rb +0 -1
  44. data/test/lib/slim-rails_assets_test.rb +0 -34
  45. data/test/test_helper.rb +0 -66
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 85d2a7934c6ad9ff0ae65c4da40ee1a7f22de8c82cf457898e977153bb3f5fa6
4
- data.tar.gz: 6ae09a270eaed5a03d87eb2a7999ef7310030ece13167efe32290ae56088cfdd
3
+ metadata.gz: 1b283190f2ca2912e814ef840f67711519392f8c339bc206d0b657d6c73161e8
4
+ data.tar.gz: b3b718e263251aa9105bdd41fda74b0c29059eb99d0fa89193a5be025385d3aa
5
5
  SHA512:
6
- metadata.gz: 5384a517144559f59493d78a1da1b5483680d89974495d91a58197b6fb5ff2655b2ca47a22e24b1e45fd074fa3f34abc00d47d727263ce7a8171ae3f80913835
7
- data.tar.gz: ac6118fbbe095c820280e0d12304d2443a9d18ca486f652a645c3ebaae57d0e06c8d4f610faaf755f4107548db2e6658ce6c9d07e820acf3201dab92d53467fc
6
+ metadata.gz: e59df33cbb85d0582050bf47800362f9f353230e2e6cd487921a33d36bc30ead174701be0b0681bea5a6a6b1699c58979e355509f2f23490b7fafc90993f5aaa
7
+ data.tar.gz: 0544655150a9a26c4a3d9f8dbd34b7d85b5ce8b6aa39f7e34bdcfc7d8459a5a163f126433e7cd40a823b966fd2699ed6db078397ff841bd38b815856fe2283fd
data/CHANGELOG.md CHANGED
@@ -1,3 +1,24 @@
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
+
10
+ ## 3.4.0 (March 2022)
11
+
12
+ * Updated templates to Rails 7 style (thanks github.com/viktorianer) (#178)
13
+
14
+
15
+ ## 3.3.0 (July 19, 2021)
16
+
17
+ * Enabled asset helpers in precompiled templates (#135)
18
+ * Tested with Rails 6.0, 6.1 and Ruby 3.0
19
+ * Improved CI and tests with Sprockets 4
20
+
21
+
1
22
  ## 3.2.0 (October 7, 2018)
2
23
 
3
24
  * Support for Slim 4
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
@@ -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
25
  Every time you generate a controller or scaffold, you'll get Slim templates.
@@ -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
@@ -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 %>
@@ -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
@@ -16,10 +16,10 @@ table
16
16
  <% attributes.each do |attribute| -%>
17
17
  td = <%= singular_table_name %>.<%= attribute.name %>
18
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
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
22
 
23
23
  br
24
24
 
25
- = link_to 'New <%= human_name %>', new_<%= singular_table_name %>_path
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
@@ -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
@@ -1,22 +1,31 @@
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
- class ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
6
- source_root File.expand_path(File.join('..', 'templates'), __FILE__)
5
+ class ScaffoldGenerator < Erb::Generators::ScaffoldGenerator # :nodoc:
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)
16
+ end
17
+
18
+ if ::Rails::VERSION::MAJOR >= 7
19
+ template "partial.html.slim", File.join("app/views", controller_file_path, "_#{singular_name}.html.slim")
12
20
  end
13
21
  end
14
22
 
15
23
  hook_for :form_builder, as: :scaffold
16
24
 
17
25
  protected
26
+
18
27
  def available_views
19
- ['index', 'edit', 'show', 'new', '_form']
28
+ %w[index edit show new _form]
20
29
  end
21
30
 
22
31
  def handler
@@ -0,0 +1,28 @@
1
+ = form_with(model: @<%= model_resource_name %>) do |form|
2
+ - if @<%= singular_table_name %>.errors.any?
3
+ div style="color: red"
4
+ h2 = "#{pluralize(@<%= singular_table_name %>.errors.count, "error")} prohibited this <%= singular_table_name %> from being saved:"
5
+ ul
6
+ - @<%= singular_table_name %>.errors.each do |error|
7
+ li = error.full_message
8
+
9
+ <% attributes.each do |attribute| -%>
10
+ div
11
+ <% if attribute.password_digest? -%>
12
+ = form.label :password, style: "display: block"
13
+ = form.password_field :password
14
+
15
+ div
16
+ = form.label :password_confirmation, style: "display: block"
17
+ = form.password_field :password_confirmation
18
+ <% elsif attribute.attachments? -%>
19
+ = form.label :<%= attribute.column_name %>, style: "display: block"
20
+ = form.<%= attribute.field_type %> :<%= attribute.column_name %>, multiple: true
21
+ <% else -%>
22
+ = form.label :<%= attribute.column_name %>, style: "display: block"
23
+ = form.<%= attribute.field_type %> :<%= attribute.column_name %>
24
+ <% end -%>
25
+
26
+ <% end -%>
27
+ div
28
+ = form.submit
@@ -0,0 +1,10 @@
1
+ h1 Editing <%= human_name.downcase %>
2
+
3
+ == render "form", <%= singular_table_name %>: @<%= singular_table_name %>
4
+
5
+ br
6
+
7
+ div
8
+ => link_to "Show this <%= human_name.downcase %>", <%= model_resource_name(prefix: "@") %>
9
+ '|
10
+ =< link_to "Back to <%= human_name.pluralize.downcase %>", <%= index_helper(type: :path) %>
@@ -0,0 +1,11 @@
1
+ p style="color: green" = notice
2
+
3
+ h1 <%= human_name.pluralize %>
4
+
5
+ #<%= plural_table_name %>
6
+ - @<%= plural_table_name %>.each do |<%= singular_table_name %>|
7
+ == render <%= singular_table_name %>
8
+ p
9
+ = link_to "Show this <%= human_name.downcase %>", <%= model_resource_name(singular_table_name) %>
10
+
11
+ = link_to "New <%= human_name.downcase %>", <%= new_helper(type: :path) %>
@@ -0,0 +1,8 @@
1
+ h1 New <%= human_name.downcase %>
2
+
3
+ == render "form", <%= singular_table_name %>: @<%= singular_table_name %>
4
+
5
+ br
6
+
7
+ div
8
+ = link_to "Back to <%= human_name.pluralize.downcase %>", <%= index_helper(type: :path) %>
@@ -0,0 +1,14 @@
1
+ div id="#{dom_id <%= singular_name %>}"
2
+ <% attributes.reject(&:password_digest?).each do |attribute| -%>
3
+ p
4
+ strong <%= attribute.human_name %>:
5
+ <% if attribute.attachment? -%>
6
+ = link_to <%= singular_name %>.<%= attribute.column_name %>.filename, <%= singular_name %>.<%= attribute.column_name %> if <%= singular_name %>.<%= attribute.column_name %>.attached?
7
+ <% elsif attribute.attachments? -%>
8
+ - <%= singular_name %>.<%= attribute.column_name %>.each do |<%= attribute.singular_name %>|
9
+ div
10
+ = link_to <%= attribute.singular_name %>.filename, <%= attribute.singular_name %>
11
+ <% else -%>
12
+ =< <%= singular_name %>.<%= attribute.column_name %>
13
+ <% end -%>
14
+ <% end -%>
@@ -0,0 +1,10 @@
1
+ p style="color: green" = notice
2
+
3
+ == render @<%= singular_table_name %>
4
+
5
+ div
6
+ => link_to "Edit this <%= human_name.downcase %>", <%= edit_helper(type: :path) %>
7
+ '|
8
+ =< link_to "Back to <%= human_name.pluralize.downcase %>", <%= index_helper(type: :path) %>
9
+
10
+ = button_to "Destroy this <%= human_name.downcase %>", <%= model_resource_name(prefix: "@") %>, method: :delete
@@ -3,7 +3,8 @@ 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
 
@@ -22,7 +23,7 @@ module Slim
22
23
  return unless app.assets
23
24
  return unless app.assets.respond_to?(:register_engine)
24
25
 
25
- app.assets.register_engine('.slim', Slim::Template)
26
+ app.assets.register_engine(".slim", Slim::Template)
26
27
  end
27
28
 
28
29
  def _register_engine(config)
@@ -30,11 +31,11 @@ module Slim
30
31
 
31
32
  config.assets.configure do |env|
32
33
  if env.respond_to?(:register_transformer) && Sprockets::VERSION.to_i > 3
33
- env.register_mime_type 'text/slim', extensions: ['.slim', '.slim.html']#, charset: :html
34
- 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
35
36
  elsif env.respond_to?(:register_engine)
36
- args = ['.slim', Slim::Template]
37
- 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")
38
39
  env.register_engine(*args)
39
40
  end
40
41
  end
@@ -1,5 +1,5 @@
1
1
  module Slim
2
2
  module Rails
3
- VERSION = '3.2.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,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slim-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 3.5.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: 2018-10-07 00:00:00.000000000 Z
12
+ date: 2022-05-09 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: actionpack
@@ -72,6 +73,20 @@ dependencies:
72
73
  - - ">="
73
74
  - !ruby/object:Gem::Version
74
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
75
90
  - !ruby/object:Gem::Dependency
76
91
  name: rocco
77
92
  requirement: !ruby/object:Gem::Requirement
@@ -142,28 +157,31 @@ dependencies:
142
157
  - - ">="
143
158
  - !ruby/object:Gem::Version
144
159
  version: '0'
145
- description: Provides the generator settings required for Rails 3+ to use Slim
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'
174
+ description: Provides the generator settings required for Rails to use Slim
146
175
  email:
147
176
  - lalmeida08@gmail.com
177
+ - janusz.m@gmail.com
148
178
  executables: []
149
179
  extensions: []
150
180
  extra_rdoc_files: []
151
181
  files:
152
- - ".gitignore"
153
- - ".travis.yml"
154
- - Appraisals
155
182
  - CHANGELOG.md
156
- - Gemfile
157
183
  - LICENSE
158
184
  - README.md
159
- - Rakefile
160
- - gemfiles/rails_3.gemfile
161
- - gemfiles/rails_4.1.gemfile
162
- - gemfiles/rails_4.2.gemfile
163
- - gemfiles/rails_4.gemfile
164
- - gemfiles/rails_5.1.gemfile
165
- - gemfiles/rails_5.2.gemfile
166
- - gemfiles/rails_5.gemfile
167
185
  - lib/generators/slim/controller/controller_generator.rb
168
186
  - lib/generators/slim/controller/templates/view.html.slim
169
187
  - lib/generators/slim/mailer/mailer_generator.rb
@@ -171,28 +189,26 @@ files:
171
189
  - lib/generators/slim/mailer/templates/layout.text.slim
172
190
  - lib/generators/slim/mailer/templates/view.html.slim
173
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
174
197
  - lib/generators/slim/scaffold/scaffold_generator.rb
175
- - lib/generators/slim/scaffold/templates/_form.html.slim
176
- - lib/generators/slim/scaffold/templates/edit.html.slim
177
- - lib/generators/slim/scaffold/templates/index.html.slim
178
- - lib/generators/slim/scaffold/templates/new.html.slim
179
- - lib/generators/slim/scaffold/templates/show.html.slim
198
+ - lib/generators/slim/scaffold/templates/_form.html.slim.tt
199
+ - lib/generators/slim/scaffold/templates/edit.html.slim.tt
200
+ - lib/generators/slim/scaffold/templates/index.html.slim.tt
201
+ - lib/generators/slim/scaffold/templates/new.html.slim.tt
202
+ - lib/generators/slim/scaffold/templates/partial.html.slim.tt
203
+ - lib/generators/slim/scaffold/templates/show.html.slim.tt
180
204
  - lib/slim-rails.rb
181
205
  - lib/slim-rails/register_engine.rb
182
206
  - lib/slim-rails/version.rb
183
- - slim-rails.gemspec
184
- - test/fixtures/routes.rb
185
- - test/lib/generators/slim/controller_generator_test.rb
186
- - test/lib/generators/slim/mailer_generator_test.rb
187
- - test/lib/generators/slim/scaffold_generator_test.rb
188
- - test/lib/generators/slim/testing_helper.rb
189
- - test/lib/slim-rails_assets_test.rb
190
- - test/test_helper.rb
191
207
  homepage: https://github.com/slim-template/slim-rails
192
208
  licenses:
193
209
  - MIT
194
210
  metadata: {}
195
- post_install_message:
211
+ post_install_message:
196
212
  rdoc_options: []
197
213
  require_paths:
198
214
  - lib
@@ -207,16 +223,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
207
223
  - !ruby/object:Gem::Version
208
224
  version: '0'
209
225
  requirements: []
210
- rubyforge_project:
211
- rubygems_version: 2.7.6
212
- signing_key:
226
+ rubygems_version: 3.3.7
227
+ signing_key:
213
228
  specification_version: 4
214
- summary: Slim templates generator for Rails 3+
215
- test_files:
216
- - test/fixtures/routes.rb
217
- - test/lib/generators/slim/controller_generator_test.rb
218
- - test/lib/generators/slim/mailer_generator_test.rb
219
- - test/lib/generators/slim/scaffold_generator_test.rb
220
- - test/lib/generators/slim/testing_helper.rb
221
- - test/lib/slim-rails_assets_test.rb
222
- - test/test_helper.rb
229
+ summary: Slim templates generator for Rails
230
+ test_files: []
data/.gitignore DELETED
@@ -1,20 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp/
18
- .ruby-version
19
- .ruby-gemset
20
- gemfiles/*.gemfile.lock
data/.travis.yml DELETED
@@ -1,50 +0,0 @@
1
- language: ruby
2
- before_install:
3
- - gem install bundler
4
- rvm:
5
- - ruby-head
6
- - 2.5
7
- - 2.4
8
- - 2.3
9
- - 2.2
10
- - 2.1
11
- - 2.0
12
- gemfile:
13
- - gemfiles/rails_3.gemfile
14
- - gemfiles/rails_4.gemfile
15
- - gemfiles/rails_4.1.gemfile
16
- - gemfiles/rails_4.2.gemfile
17
- - gemfiles/rails_5.gemfile
18
- - gemfiles/rails_5.1.gemfile
19
- - gemfiles/rails_5.2.gemfile
20
- matrix:
21
- allow_failures:
22
- - rvm: ruby-head
23
- - rvm: 2.4
24
- gemfile: gemfiles/rails_4.gemfile
25
- - rvm: 2.4
26
- gemfile: gemfiles/rails_4.1.gemfile
27
- - rvm: 2.4
28
- gemfile: gemfiles/rails_4.2.gemfile
29
- - rvm: 2.5
30
- gemfile: gemfiles/rails_4.gemfile
31
- - rvm: 2.5
32
- gemfile: gemfiles/rails_4.1.gemfile
33
- - rvm: 2.5
34
- gemfile: gemfiles/rails_4.2.gemfile
35
- exclude:
36
- - rvm: 2.1
37
- gemfile: gemfiles/rails_5.gemfile
38
- - rvm: 2.1
39
- gemfile: gemfiles/rails_5.1.gemfile
40
- - rvm: 2.1
41
- gemfile: gemfiles/rails_5.2.gemfile
42
- - rvm: 2.0
43
- gemfile: gemfiles/rails_5.gemfile
44
- - rvm: 2.0
45
- gemfile: gemfiles/rails_5.1.gemfile
46
- - rvm: 2.0
47
- gemfile: gemfiles/rails_5.2.gemfile
48
- addons:
49
- code_climate:
50
- repo_token: 294f0ec8183176c0259b75eb21b38414508616985a7b39fc48fec9dfcf40a52e
data/Appraisals DELETED
@@ -1,29 +0,0 @@
1
- appraise "rails-3" do
2
- gem "rails", "~> 3.2"
3
- gem 'minitest'
4
- gem 'test-unit', '~> 3.0'
5
- end
6
-
7
- appraise "rails-4" do
8
- gem "rails", "~> 4.0.0"
9
- end
10
-
11
- appraise "rails-4.1" do
12
- gem "rails", "~> 4.1.0"
13
- end
14
-
15
- appraise "rails-4.2" do
16
- gem "rails", "~> 4.2.0"
17
- end
18
-
19
- appraise "rails-5" do
20
- gem "rails", "~> 5.0.0"
21
- end
22
-
23
- appraise "rails-5.1" do
24
- gem "rails", "~> 5.1.0"
25
- end
26
-
27
- appraise "rails-5.2" do
28
- gem "rails", "~> 5.2.0"
29
- end
data/Gemfile DELETED
@@ -1,3 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec
data/Rakefile DELETED
@@ -1,12 +0,0 @@
1
- #!/usr/bin/env rake
2
- require 'bundler'
3
- Bundler::GemHelper.install_tasks
4
-
5
- require 'rake/testtask'
6
- Rake::TestTask.new(:test) do |test|
7
- test.libs << 'lib' << 'test'
8
- test.pattern = 'test/**/*_test.rb'
9
- test.verbose = true
10
- end
11
-
12
- task :default => :test
@@ -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: "../"
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 4.1.0"
6
-
7
- gemspec path: "../"
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 4.2.0"
6
-
7
- gemspec path: "../"
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 4.0.0"
6
-
7
- gemspec path: "../"
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 5.1.0"
6
-
7
- gemspec path: "../"
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 5.2.0"
6
-
7
- gemspec path: "../"
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 5.0.0"
6
-
7
- gemspec path: "../"
@@ -1,8 +0,0 @@
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
8
-
@@ -1,5 +0,0 @@
1
- h1 New <%= singular_table_name %>
2
-
3
- == render 'form'
4
-
5
- = link_to 'Back', <%= index_helper %>_path
data/slim-rails.gemspec DELETED
@@ -1,34 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'slim-rails/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = 'slim-rails'
8
- spec.version = Slim::Rails::VERSION
9
- spec.authors = ["Leonardo Almeida"]
10
- spec.email = ["lalmeida08@gmail.com"]
11
-
12
- spec.summary = 'Slim templates generator for Rails 3+'
13
- spec.description = 'Provides the generator settings required for Rails 3+ to use Slim'
14
- spec.homepage = 'https://github.com/slim-template/slim-rails'
15
- spec.license = 'MIT'
16
-
17
- spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
- spec.files = `git ls-files`.split("\n")
19
- spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
- spec.require_paths = ['lib']
21
-
22
- spec.required_ruby_version = '>= 2.0.0'
23
-
24
- spec.add_runtime_dependency 'actionpack', ['>= 3.1']
25
- spec.add_runtime_dependency 'railties', ['>= 3.1']
26
- spec.add_runtime_dependency 'slim', ['>= 3.0', '< 5.0']
27
-
28
- spec.add_development_dependency 'sprockets-rails'
29
- spec.add_development_dependency 'rocco'
30
- spec.add_development_dependency 'redcarpet'
31
- spec.add_development_dependency 'awesome_print'
32
- spec.add_development_dependency 'actionmailer', ['>= 3.1']
33
- spec.add_development_dependency 'appraisal'
34
- end
@@ -1,58 +0,0 @@
1
- TestApp.routes.draw do
2
- # The priority is based upon order of creation:
3
- # first created -> highest priority.
4
-
5
- # Sample of regular route:
6
- # match 'products/:id' => 'catalog#view'
7
- # Keep in mind you can assign values other than :controller and :action
8
-
9
- # Sample of named route:
10
- # match 'products/:id/purchase' => 'catalog#purchase', as: :purchase
11
- # This route can be invoked with purchase_url(id: product.id)
12
-
13
- # Sample resource route (maps HTTP verbs to controller actions automatically):
14
- # resources :products
15
-
16
- # Sample resource route with options:
17
- # resources :products do
18
- # member do
19
- # get :short
20
- # post :toggle
21
- # end
22
- #
23
- # collection do
24
- # get :sold
25
- # end
26
- # end
27
-
28
- # Sample resource route with sub-resources:
29
- # resources :products do
30
- # resources :comments, :sales
31
- # resource :seller
32
- # end
33
-
34
- # Sample resource route with more complex sub-resources
35
- # resources :products do
36
- # resources :comments
37
- # resources :sales do
38
- # get :recent, on: :collection
39
- # end
40
- # end
41
-
42
- # Sample resource route within a namespace:
43
- # namespace :admin do
44
- # # Directs /admin/products/* to Admin::ProductsController
45
- # # (app/controllers/admin/products_controller.rb)
46
- # resources :products
47
- # end
48
-
49
- # You can have the root of your site routed with "root"
50
- # just remember to delete public/index.html.
51
- # root to: "welcome#index"
52
-
53
- # See how all your routes lay out with "rake routes"
54
-
55
- # This is a legacy wild controller route that's not recommended for RESTful applications.
56
- # Note: This route will make all actions in every controller accessible via GET requests.
57
- # match ':controller(/:action(/:id(.:format)))'
58
- end
@@ -1,17 +0,0 @@
1
- require 'test_helper'
2
- require 'lib/generators/slim/testing_helper'
3
-
4
- class Slim::Generators::ControllerGeneratorTest < Rails::Generators::TestCase
5
- destination File.join(Rails.root)
6
- tests Rails::Generators::ControllerGenerator
7
- arguments %w(Account foo bar --template-engine slim)
8
-
9
- setup :prepare_destination
10
- setup :copy_routes
11
-
12
- test "should invoke template engine" do
13
- run_generator
14
- assert_file File.join("app", "views", "account", "foo.html.slim"), %r(app/views/account/foo\.html\.slim)
15
- assert_file File.join("app", "views", "account", "bar.html.slim"), %r(app/views/account/bar\.html\.slim)
16
- end
17
- end
@@ -1,70 +0,0 @@
1
- require 'test_helper'
2
- require 'lib/generators/slim/testing_helper'
3
-
4
- class Slim::Generators::MailerGeneratorTest < Rails::Generators::TestCase
5
- destination File.join(Rails.root)
6
- tests Rails::Generators::MailerGenerator
7
- arguments %w(notifier foo bar --template-engine slim)
8
-
9
- setup :prepare_destination
10
- setup :copy_routes
11
-
12
- test "should invoke template engine" do
13
- run_generator
14
-
15
- rails_version = ::Rails.version.to_s
16
-
17
- if rails_version >= '5.0'
18
- assert_file "app/views/notifier_mailer/foo.html.slim" do |view|
19
- assert_match %r(app/views/notifier_mailer/foo\.html\.slim), view
20
- assert_match(/\= @greeting/, view)
21
- end
22
-
23
- assert_file "app/views/notifier_mailer/bar.html.slim" do |view|
24
- assert_match %r(app/views/notifier_mailer/bar\.html\.slim), view
25
- assert_match(/\= @greeting/, view)
26
- end
27
-
28
- assert_file "app/views/notifier_mailer/foo.text.slim" do |view|
29
- assert_match %r(app/views/notifier_mailer/foo\.text\.slim), view
30
- assert_match(/@greeting/, view)
31
- end
32
-
33
- assert_file "app/views/notifier_mailer/bar.text.slim" do |view|
34
- assert_match %r(app/views/notifier_mailer/bar\.text\.slim), view
35
- assert_match(/@greeting/, view)
36
- end
37
- else
38
- if rails_version >= '4.2'
39
- assert_file "app/views/layouts/mailer.text.slim" do |view|
40
- assert_match(/\= yield/, view)
41
- end
42
-
43
- assert_file "app/views/layouts/mailer.html.slim" do |view|
44
- assert_match(/\= yield/, view)
45
- end
46
-
47
- assert_file "app/views/notifier/foo.html.slim" do |view|
48
- assert_match %r(app/views/notifier/foo\.html\.slim), view
49
- assert_match(/\= @greeting/, view)
50
- end
51
-
52
- assert_file "app/views/notifier/bar.html.slim" do |view|
53
- assert_match %r(app/views/notifier/bar\.html\.slim), view
54
- assert_match(/\= @greeting/, view)
55
- end
56
-
57
- end
58
-
59
- assert_file "app/views/notifier/foo.text.slim" do |view|
60
- assert_match %r(app/views/notifier/foo\.text\.slim), view
61
- assert_match(/@greeting/, view)
62
- end
63
-
64
- assert_file "app/views/notifier/bar.text.slim" do |view|
65
- assert_match %r(app/views/notifier/bar\.text\.slim), view
66
- assert_match(/@greeting/, view)
67
- end
68
- end
69
- end
70
- end
@@ -1,26 +0,0 @@
1
- require 'test_helper'
2
- require 'lib/generators/slim/testing_helper'
3
-
4
- class Slim::Generators::ScaffoldGeneratorTest < Rails::Generators::TestCase
5
- destination File.join(Rails.root)
6
- tests Rails::Generators::ScaffoldGenerator
7
- arguments %w(product_line title:string price:integer --template-engine slim --orm active-record)
8
-
9
- setup :prepare_destination
10
- setup :copy_routes
11
-
12
- test "should invoke template engine" do
13
- run_generator
14
-
15
- %w(index edit new show _form).each { |view| assert_file File.join "app", "views", "product_lines", "#{view}.html.slim" }
16
- assert_no_file File.join "app", "views", "layouts", "product_lines.html.slim"
17
- end
18
-
19
- test "should revoke template engine" do
20
- run_generator
21
- run_generator ["product_line", "--orm", "active-record"], behavior: :revoke
22
-
23
- assert_no_file File.join "app", "views", "product_lines"
24
- assert_no_file File.join "app", "views", "layouts", "product_lines.html.slim"
25
- end
26
- end
@@ -1 +0,0 @@
1
- require_generators slim: ['scaffold', 'controller', 'mailer']
@@ -1,34 +0,0 @@
1
- require 'test_helper'
2
- require 'tmpdir'
3
-
4
- class Slim::Rails::AssetsTest < ActiveSupport::TestCase
5
- def with_app(use_sprockets, code)
6
- Dir.mktmpdir do |dir|
7
- app_path = File.join(dir, 'app.rb')
8
- File.write(app_path, <<-APP)
9
- require 'rails'
10
- require 'sprockets/railtie' if #{use_sprockets}
11
- require 'slim-rails'
12
- class DummyApp < ::Rails::Application
13
- config.root = #{dir.inspect}
14
- config.assets.enabled = true if #{use_sprockets}
15
- config.eager_load = false
16
- end
17
- DummyApp.initialize!
18
- #{code}
19
- APP
20
-
21
- asset_path = File.join(dir, 'app', 'assets', 'html', 'test.slim')
22
- FileUtils.mkdir_p(File.dirname(asset_path))
23
- File.write(asset_path, ".test\n | hi")
24
-
25
- `BUNDLE_GEMFILE=#{ENV['BUNDLE_GEMFILE']} bundle exec ruby #{app_path}`
26
- end
27
- end
28
-
29
- test 'compile slim view' do
30
- assert_equal 'ok', with_app(false, 'print DummyApp.assets || "ok"')
31
- assert_equal '<div class="test">hi</div>', with_app(true, 'print DummyApp.assets["test.slim"].to_s')
32
- assert_equal '<div class="test">hi</div>', with_app(true, 'print DummyApp.assets["test", accept: "text/html"].to_s')
33
- end
34
- end
data/test/test_helper.rb DELETED
@@ -1,66 +0,0 @@
1
- require 'rubygems'
2
- require 'minitest/autorun'
3
- require 'rails'
4
- require 'rails/test_help'
5
- require 'rails/generators'
6
- require 'rails/generators/test_case'
7
- require 'slim-rails'
8
-
9
- class TestApp < Rails::Application
10
- config.root = File.dirname(__FILE__)
11
- end
12
- Rails.application = TestApp
13
-
14
- module Rails
15
- def self.root
16
- @root ||= File.expand_path(File.join(File.dirname(__FILE__), '..', 'tmp', 'rails'))
17
- end
18
- end
19
- Rails.application.config.root = Rails.root
20
-
21
- Rails::Generators.configure! Rails.application.config.generators
22
-
23
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
24
-
25
- def copy_routes
26
- routes = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'routes.rb'))
27
- destination = File.join(Rails.root, "config")
28
- FileUtils.mkdir_p(destination)
29
- FileUtils.cp File.expand_path(routes), destination
30
- end
31
-
32
- def assert_class(klass, content)
33
- assert content =~ /class #{klass}(\(.+\))?(.*?)\nend/m, "Expected to have class #{klass}"
34
- yield $2.strip if block_given?
35
- end
36
-
37
- def generator_list
38
- {
39
- rails: ['scaffold', 'controller', 'mailer'],
40
- slim: ['scaffold', 'controller', 'mailer']
41
- }
42
- end
43
-
44
- def path_prefix(name)
45
- case name
46
- when :rails
47
- 'rails/generators'
48
- else
49
- 'generators'
50
- end
51
- end
52
-
53
- def require_generators(generator_list)
54
- generator_list.each do |name, generators|
55
- generators.each do |generator_name|
56
- if name.to_s == 'rails' && generator_name.to_s == 'mailer'
57
- require File.join(path_prefix(name), generator_name.to_s, "#{generator_name}_generator")
58
- else
59
- require File.join(path_prefix(name), name.to_s, generator_name.to_s, "#{generator_name}_generator")
60
- end
61
- end
62
- end
63
- end
64
- alias :require_generator :require_generators
65
-
66
- require_generators generator_list