slim-rails 3.1.3 → 3.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +17 -0
- data/README.md +4 -2
- data/lib/generators/slim/mailer/templates/view.html.slim +1 -1
- data/lib/generators/slim/mailer/templates/view.text.slim +1 -1
- data/lib/generators/slim/scaffold/scaffold_generator.rb +5 -2
- data/lib/generators/slim/scaffold/templates/_form.html.slim.tt +28 -0
- data/lib/generators/slim/scaffold/templates/edit.html.slim.tt +10 -0
- data/lib/generators/slim/scaffold/templates/index.html.slim.tt +11 -0
- data/lib/generators/slim/scaffold/templates/new.html.slim.tt +8 -0
- data/lib/generators/slim/scaffold/templates/partial.html.slim.tt +14 -0
- data/lib/generators/slim/scaffold/templates/show.html.slim.tt +10 -0
- data/lib/slim-rails/register_engine.rb +26 -23
- data/lib/slim-rails/version.rb +1 -1
- metadata +39 -42
- data/.gitignore +0 -20
- data/.travis.yml +0 -33
- data/Appraisals +0 -21
- data/Gemfile +0 -3
- data/Rakefile +0 -12
- data/gemfiles/rails_3.gemfile +0 -9
- data/gemfiles/rails_4.1.gemfile +0 -7
- data/gemfiles/rails_4.2.gemfile +0 -7
- data/gemfiles/rails_4.gemfile +0 -7
- data/gemfiles/rails_5.gemfile +0 -7
- data/lib/generators/slim/scaffold/templates/_form.html.slim +0 -14
- data/lib/generators/slim/scaffold/templates/edit.html.slim +0 -8
- data/lib/generators/slim/scaffold/templates/index.html.slim +0 -25
- data/lib/generators/slim/scaffold/templates/new.html.slim +0 -5
- data/lib/generators/slim/scaffold/templates/show.html.slim +0 -11
- data/slim-rails.gemspec +0 -34
- data/test/fixtures/routes.rb +0 -58
- data/test/lib/generators/slim/controller_generator_test.rb +0 -17
- data/test/lib/generators/slim/mailer_generator_test.rb +0 -70
- data/test/lib/generators/slim/scaffold_generator_test.rb +0 -26
- data/test/lib/generators/slim/testing_helper.rb +0 -1
- data/test/lib/slim-rails_assets_test.rb +0 -34
- data/test/test_helper.rb +0 -66
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9d672f03fbbe43effd0e993addabdd6ab61bbda0038edee278359483363caa98
|
4
|
+
data.tar.gz: 98e150a881b76c14f4304728124366b44ce3d4335b9cb732cd6bbe6668c6011f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4e81e2fe65f34fb318c40bf799dff4498010699a4721014f0b9c2e648c7e14ea6e19c1dd95c7e12aade2d82e7043cb1885560759874efd4e15f19a006109b55
|
7
|
+
data.tar.gz: db4ed0ed081659fdd329345054bcdf1252437b69c8433aa045a1ede11211d0cda09e8754cca43a4a929226ba802637eccbc9fbb3988738761960d28ae8690a0d
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
## 3.4.0 (March 2022)
|
2
|
+
|
3
|
+
* Updated templates to Rails 7 style (thanks github.com/viktorianer) (#178)
|
4
|
+
|
5
|
+
|
6
|
+
## 3.3.0 (July 19, 2021)
|
7
|
+
|
8
|
+
* Enabled asset helpers in precompiled templates (#135)
|
9
|
+
* Tested with Rails 6.0, 6.1 and Ruby 3.0
|
10
|
+
* Improved CI and tests with Sprockets 4
|
11
|
+
|
12
|
+
|
13
|
+
## 3.2.0 (October 7, 2018)
|
14
|
+
|
15
|
+
* Support for Slim 4
|
16
|
+
|
17
|
+
|
1
18
|
## 3.1.3 (April 3, 2017)
|
2
19
|
|
3
20
|
* Improved compatibility with Sprockets 4
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# slim-rails [![Build Status](https://travis-ci.org/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.
|
@@ -1,2 +1,2 @@
|
|
1
1
|
h1 <%= class_name %>#<%= @action %>
|
2
|
-
p = @greeting
|
2
|
+
p = "#{@greeting}, find me in <%= @path %>"
|
@@ -2,7 +2,7 @@ require 'rails/generators/erb/scaffold/scaffold_generator'
|
|
2
2
|
|
3
3
|
module Slim
|
4
4
|
module Generators
|
5
|
-
class ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
5
|
+
class ScaffoldGenerator < Erb::Generators::ScaffoldGenerator # :nodoc:
|
6
6
|
source_root File.expand_path(File.join('..', 'templates'), __FILE__)
|
7
7
|
|
8
8
|
def copy_view_files
|
@@ -10,13 +10,16 @@ module Slim
|
|
10
10
|
filename = filename_with_extensions view
|
11
11
|
template "#{view}.html.slim", File.join('app', 'views', controller_file_path, filename)
|
12
12
|
end
|
13
|
+
|
14
|
+
template 'partial.html.slim', File.join('app/views', controller_file_path, "_#{singular_name}.html.slim")
|
13
15
|
end
|
14
16
|
|
15
17
|
hook_for :form_builder, as: :scaffold
|
16
18
|
|
17
19
|
protected
|
20
|
+
|
18
21
|
def available_views
|
19
|
-
[
|
22
|
+
%w[index edit show new _form]
|
20
23
|
end
|
21
24
|
|
22
25
|
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,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,38 +3,41 @@ module Slim
|
|
3
3
|
module RegisterEngine
|
4
4
|
class Transformer
|
5
5
|
def self.call(input)
|
6
|
-
|
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
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
19
|
|
18
|
-
|
20
|
+
private
|
19
21
|
|
20
|
-
|
21
|
-
|
22
|
-
|
22
|
+
def _register_engine3(app)
|
23
|
+
return unless app.assets
|
24
|
+
return unless app.assets.respond_to?(:register_engine)
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
+
app.assets.register_engine('.slim', Slim::Template)
|
27
|
+
end
|
26
28
|
|
27
|
-
|
28
|
-
|
29
|
+
def _register_engine(config)
|
30
|
+
return unless config.respond_to?(:assets)
|
29
31
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
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
|
38
41
|
end
|
39
42
|
end
|
40
43
|
end
|
data/lib/slim-rails/version.rb
CHANGED
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.
|
4
|
+
version: 3.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leonardo Almeida
|
8
|
-
|
8
|
+
- Janusz Mordarski
|
9
|
+
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2022-03-15 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,26 +157,17 @@ dependencies:
|
|
136
157
|
- - ">="
|
137
158
|
- !ruby/object:Gem::Version
|
138
159
|
version: '0'
|
139
|
-
description: Provides the generator settings required for Rails
|
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: []
|
145
167
|
files:
|
146
|
-
- ".gitignore"
|
147
|
-
- ".travis.yml"
|
148
|
-
- Appraisals
|
149
168
|
- CHANGELOG.md
|
150
|
-
- Gemfile
|
151
169
|
- LICENSE
|
152
170
|
- README.md
|
153
|
-
- Rakefile
|
154
|
-
- gemfiles/rails_3.gemfile
|
155
|
-
- gemfiles/rails_4.1.gemfile
|
156
|
-
- gemfiles/rails_4.2.gemfile
|
157
|
-
- gemfiles/rails_4.gemfile
|
158
|
-
- gemfiles/rails_5.gemfile
|
159
171
|
- lib/generators/slim/controller/controller_generator.rb
|
160
172
|
- lib/generators/slim/controller/templates/view.html.slim
|
161
173
|
- lib/generators/slim/mailer/mailer_generator.rb
|
@@ -164,27 +176,20 @@ files:
|
|
164
176
|
- lib/generators/slim/mailer/templates/view.html.slim
|
165
177
|
- lib/generators/slim/mailer/templates/view.text.slim
|
166
178
|
- lib/generators/slim/scaffold/scaffold_generator.rb
|
167
|
-
- lib/generators/slim/scaffold/templates/_form.html.slim
|
168
|
-
- lib/generators/slim/scaffold/templates/edit.html.slim
|
169
|
-
- lib/generators/slim/scaffold/templates/index.html.slim
|
170
|
-
- lib/generators/slim/scaffold/templates/new.html.slim
|
171
|
-
- lib/generators/slim/scaffold/templates/
|
179
|
+
- lib/generators/slim/scaffold/templates/_form.html.slim.tt
|
180
|
+
- lib/generators/slim/scaffold/templates/edit.html.slim.tt
|
181
|
+
- lib/generators/slim/scaffold/templates/index.html.slim.tt
|
182
|
+
- lib/generators/slim/scaffold/templates/new.html.slim.tt
|
183
|
+
- lib/generators/slim/scaffold/templates/partial.html.slim.tt
|
184
|
+
- lib/generators/slim/scaffold/templates/show.html.slim.tt
|
172
185
|
- lib/slim-rails.rb
|
173
186
|
- lib/slim-rails/register_engine.rb
|
174
187
|
- lib/slim-rails/version.rb
|
175
|
-
- slim-rails.gemspec
|
176
|
-
- test/fixtures/routes.rb
|
177
|
-
- test/lib/generators/slim/controller_generator_test.rb
|
178
|
-
- test/lib/generators/slim/mailer_generator_test.rb
|
179
|
-
- test/lib/generators/slim/scaffold_generator_test.rb
|
180
|
-
- test/lib/generators/slim/testing_helper.rb
|
181
|
-
- test/lib/slim-rails_assets_test.rb
|
182
|
-
- test/test_helper.rb
|
183
188
|
homepage: https://github.com/slim-template/slim-rails
|
184
189
|
licenses:
|
185
190
|
- MIT
|
186
191
|
metadata: {}
|
187
|
-
post_install_message:
|
192
|
+
post_install_message:
|
188
193
|
rdoc_options: []
|
189
194
|
require_paths:
|
190
195
|
- lib
|
@@ -199,16 +204,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
199
204
|
- !ruby/object:Gem::Version
|
200
205
|
version: '0'
|
201
206
|
requirements: []
|
202
|
-
|
203
|
-
|
204
|
-
signing_key:
|
207
|
+
rubygems_version: 3.3.7
|
208
|
+
signing_key:
|
205
209
|
specification_version: 4
|
206
|
-
summary: Slim templates generator for Rails
|
207
|
-
test_files:
|
208
|
-
- test/fixtures/routes.rb
|
209
|
-
- test/lib/generators/slim/controller_generator_test.rb
|
210
|
-
- test/lib/generators/slim/mailer_generator_test.rb
|
211
|
-
- test/lib/generators/slim/scaffold_generator_test.rb
|
212
|
-
- test/lib/generators/slim/testing_helper.rb
|
213
|
-
- test/lib/slim-rails_assets_test.rb
|
214
|
-
- test/test_helper.rb
|
210
|
+
summary: Slim templates generator for Rails
|
211
|
+
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,33 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
before_install:
|
3
|
-
- gem install bundler
|
4
|
-
rvm:
|
5
|
-
- ruby-head
|
6
|
-
- 2.4.0
|
7
|
-
- 2.3
|
8
|
-
- 2.2
|
9
|
-
- 2.1
|
10
|
-
- 2.0
|
11
|
-
gemfile:
|
12
|
-
- gemfiles/rails_3.gemfile
|
13
|
-
- gemfiles/rails_4.gemfile
|
14
|
-
- gemfiles/rails_4.1.gemfile
|
15
|
-
- gemfiles/rails_4.2.gemfile
|
16
|
-
- gemfiles/rails_5.gemfile
|
17
|
-
matrix:
|
18
|
-
allow_failures:
|
19
|
-
- rvm: ruby-head
|
20
|
-
- rvm: 2.4.0
|
21
|
-
gemfile: gemfiles/rails_4.gemfile
|
22
|
-
- rvm: 2.4.0
|
23
|
-
gemfile: gemfiles/rails_4.1.gemfile
|
24
|
-
- rvm: 2.4.0
|
25
|
-
gemfile: gemfiles/rails_4.2.gemfile
|
26
|
-
exclude:
|
27
|
-
- rvm: 2.1
|
28
|
-
gemfile: gemfiles/rails_5.gemfile
|
29
|
-
- rvm: 2.0
|
30
|
-
gemfile: gemfiles/rails_5.gemfile
|
31
|
-
addons:
|
32
|
-
code_climate:
|
33
|
-
repo_token: 294f0ec8183176c0259b75eb21b38414508616985a7b39fc48fec9dfcf40a52e
|
data/Appraisals
DELETED
@@ -1,21 +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
|
data/Gemfile
DELETED
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
|
data/gemfiles/rails_3.gemfile
DELETED
data/gemfiles/rails_4.1.gemfile
DELETED
data/gemfiles/rails_4.2.gemfile
DELETED
data/gemfiles/rails_4.gemfile
DELETED
data/gemfiles/rails_5.gemfile
DELETED
@@ -1,14 +0,0 @@
|
|
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
|
@@ -1,25 +0,0 @@
|
|
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
|
@@ -1,11 +0,0 @@
|
|
1
|
-
p#notice = notice
|
2
|
-
|
3
|
-
<% attributes.each do |attribute| -%>
|
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
|
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']
|
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
|
data/test/fixtures/routes.rb
DELETED
@@ -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
|