slim-rails 3.4.0 → 3.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +1 -1
- data/lib/generators/slim/controller/controller_generator.rb +3 -3
- data/lib/generators/slim/mailer/mailer_generator.rb +3 -2
- data/lib/generators/slim/scaffold/legacy_templates/_form.html.slim.tt +14 -0
- data/lib/generators/slim/scaffold/legacy_templates/edit.html.slim.tt +7 -0
- data/lib/generators/slim/scaffold/legacy_templates/index.html.slim.tt +25 -0
- data/lib/generators/slim/scaffold/legacy_templates/new.html.slim.tt +5 -0
- data/lib/generators/slim/scaffold/legacy_templates/show.html.slim.tt +11 -0
- data/lib/generators/slim/scaffold/scaffold_generator.rb +10 -4
- data/lib/generators/slim/scaffold/templates/_form.html.slim.tt +1 -1
- data/lib/slim-rails/register_engine.rb +5 -5
- data/lib/slim-rails/version.rb +1 -1
- data/lib/slim-rails.rb +8 -8
- metadata +21 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2d82a2e4da0effe1238f8b1c093a6ced304557100c6c69974a4f7785348a334
|
4
|
+
data.tar.gz: 8ba702e6cf87fc64958089d6b1fc5615ea6921f81d36da27637704c9af9da9bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c24b61bc4642cc347415051b43d1621ccc7b9d7bb48a413a731f006a70c6e9e6272e77b4be0b911b42535f5822dc651e29c8abe18df1878024afa068050bb7ee
|
7
|
+
data.tar.gz: 1c544cf99a6fb8e4df7e5767421e32a96e656a33abb865576806a0a053455a06ebce3676d7adcc8207e30274e2852ced3e1963882feda97783f7f022a9c9b131
|
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://
|
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
|
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(
|
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
|
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(
|
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,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,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
|
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
|
-
|
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(
|
15
|
+
template "#{view}.html.slim", File.join("app", "views", controller_file_path, filename)
|
12
16
|
end
|
13
17
|
|
14
|
-
|
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,
|
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(
|
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
|
35
|
-
env.register_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 = [
|
38
|
-
args << {
|
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
|
data/lib/slim-rails/version.rb
CHANGED
data/lib/slim-rails.rb
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
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
|
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
|
16
|
+
begin # rubocop:disable Style/RedundantBegin
|
17
17
|
if defined?(CacheDigests::DependencyTracker)
|
18
18
|
# 'cache_digests' gem being used (overrides Rails 4 implementation)
|
19
19
|
CacheDigests::DependencyTracker.register_tracker :slim, CacheDigests::DependencyTracker::ERBTracker
|
@@ -22,9 +22,9 @@ module Slim
|
|
22
22
|
# recalculate cache digest keys for each request
|
23
23
|
CacheDigests::TemplateDigestor.cache = ActiveSupport::Cache::NullStore.new
|
24
24
|
end
|
25
|
-
elsif ::Rails.version.to_s >=
|
25
|
+
elsif ::Rails.version.to_s >= "4.0"
|
26
26
|
# will only apply if Rails 4, which includes 'action_view/dependency_tracker'
|
27
|
-
require
|
27
|
+
require "action_view/dependency_tracker"
|
28
28
|
ActionView::DependencyTracker.register_tracker :slim, ActionView::DependencyTracker::ERBTracker
|
29
29
|
end
|
30
30
|
rescue
|
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
|
+
version: 3.5.1
|
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-
|
12
|
+
date: 2022-05-10 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
|