slim-rails 3.1.0 → 3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/Appraisals +1 -1
- data/gemfiles/rails_5.gemfile +1 -1
- data/lib/slim-rails.rb +2 -3
- data/lib/slim-rails/register_engine.rb +45 -0
- data/lib/slim-rails/version.rb +1 -1
- data/slim-rails.gemspec +1 -0
- data/test/fixtures/routes.rb +1 -1
- data/test/lib/generators/slim/mailer_generator_test.rb +6 -6
- data/test/lib/slim-rails_assets_test.rb +32 -0
- data/test/test_helper.rb +3 -1
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 730249022955562dd8f32bc57713909e0e34e84c
|
4
|
+
data.tar.gz: 4ac7a9296a96b94e8106df5d1bef4423dfbe2e7b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20768a544ba036ed3351a9acbcabe7b6fcd18cf7ec50e5f4383f476d42b957b613f96c800e0e1c43d9782f79e228c80127f2b2b6d8842b3e26d8b1b9e34feb6f
|
7
|
+
data.tar.gz: d0b3b687b462254b194daaa07ff77c17ce1104007f74d33ec71bb7d9a30a64958cf3823eaae7c61ca4e4ee1659a5f8ce0782378f5b628196d286c0da3b88adc8
|
data/.travis.yml
CHANGED
@@ -11,6 +11,9 @@ gemfile:
|
|
11
11
|
- gemfiles/rails_4.gemfile
|
12
12
|
- gemfiles/rails_4.1.gemfile
|
13
13
|
- gemfiles/rails_4.2.gemfile
|
14
|
+
matrix:
|
15
|
+
allow_failures:
|
16
|
+
- rvm: ruby-head
|
14
17
|
addons:
|
15
18
|
code_climate:
|
16
19
|
repo_token: 294f0ec8183176c0259b75eb21b38414508616985a7b39fc48fec9dfcf40a52e
|
data/Appraisals
CHANGED
data/gemfiles/rails_5.gemfile
CHANGED
data/lib/slim-rails.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'slim-rails/version'
|
2
2
|
require 'rails'
|
3
3
|
require 'slim'
|
4
|
+
require 'slim-rails/register_engine'
|
4
5
|
|
5
6
|
module Slim
|
6
7
|
module Rails
|
@@ -8,9 +9,7 @@ module Slim
|
|
8
9
|
config.app_generators.template_engine :slim
|
9
10
|
|
10
11
|
initializer 'slim_rails.configure_template_digestor' do |app|
|
11
|
-
|
12
|
-
app.assets.register_engine '.slim', Slim::Template
|
13
|
-
end
|
12
|
+
Slim::Rails::RegisterEngine.register_engine(app, config)
|
14
13
|
|
15
14
|
ActiveSupport.on_load(:action_view) do
|
16
15
|
ActiveSupport.on_load(:after_initialize) do
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Slim
|
2
|
+
module Rails
|
3
|
+
module RegisterEngine
|
4
|
+
class Transformer
|
5
|
+
def self.call(input)
|
6
|
+
Slim::Template.new(input[:name]) { input[:data] }.render(nil)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.register_engine(app, config)
|
11
|
+
if ::Rails::VERSION::MAJOR == 3
|
12
|
+
_register_engine3(app)
|
13
|
+
else
|
14
|
+
_register_engine(config)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def self._register_engine3(app)
|
21
|
+
return unless app.assets
|
22
|
+
return unless app.assets.respond_to?(:register_engine)
|
23
|
+
|
24
|
+
app.assets.register_engine('.slim', Slim::Template)
|
25
|
+
end
|
26
|
+
|
27
|
+
def self._register_engine(config)
|
28
|
+
return unless config.respond_to?(:assets)
|
29
|
+
|
30
|
+
config.assets.configure do |env|
|
31
|
+
if env.respond_to?(:register_transformer)
|
32
|
+
env.register_mime_type 'text/slim', extensions: ['.slim', '.slim.html']#, charset: :html
|
33
|
+
env.register_preprocessor 'text/slim', 'text/html', RegisterEngine::Transformer
|
34
|
+
end
|
35
|
+
|
36
|
+
if env.respond_to?(:register_engine)
|
37
|
+
args = ['.slim', Slim::Template]
|
38
|
+
args << { silence_deprecation: true } if Sprockets::VERSION.start_with?("3")
|
39
|
+
env.register_engine(*args)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/slim-rails/version.rb
CHANGED
data/slim-rails.gemspec
CHANGED
@@ -25,6 +25,7 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_runtime_dependency 'railties', ['>= 3.1']
|
26
26
|
spec.add_runtime_dependency 'slim', ['~> 3.0']
|
27
27
|
|
28
|
+
spec.add_development_dependency 'sprockets-rails'
|
28
29
|
spec.add_development_dependency 'rocco'
|
29
30
|
spec.add_development_dependency 'redcarpet'
|
30
31
|
spec.add_development_dependency 'awesome_print'
|
data/test/fixtures/routes.rb
CHANGED
@@ -15,33 +15,33 @@ class Slim::Generators::MailerGeneratorTest < Rails::Generators::TestCase
|
|
15
15
|
if ::Rails.version.to_s >= '4.2'
|
16
16
|
|
17
17
|
assert_file "app/views/layouts/mailer.text.slim" do |view|
|
18
|
-
assert_match
|
18
|
+
assert_match(/\= yield/, view)
|
19
19
|
end
|
20
20
|
|
21
21
|
assert_file "app/views/layouts/mailer.html.slim" do |view|
|
22
|
-
assert_match
|
22
|
+
assert_match(/\= yield/, view)
|
23
23
|
end
|
24
24
|
|
25
25
|
assert_file "app/views/notifier/foo.html.slim" do |view|
|
26
26
|
assert_match %r(app/views/notifier/foo\.html\.slim), view
|
27
|
-
assert_match
|
27
|
+
assert_match(/\= @greeting/, view)
|
28
28
|
end
|
29
29
|
|
30
30
|
assert_file "app/views/notifier/bar.html.slim" do |view|
|
31
31
|
assert_match %r(app/views/notifier/bar\.html\.slim), view
|
32
|
-
assert_match
|
32
|
+
assert_match(/\= @greeting/, view)
|
33
33
|
end
|
34
34
|
|
35
35
|
end
|
36
36
|
|
37
37
|
assert_file "app/views/notifier/foo.text.slim" do |view|
|
38
38
|
assert_match %r(app/views/notifier/foo\.text\.slim), view
|
39
|
-
assert_match
|
39
|
+
assert_match(/@greeting/, view)
|
40
40
|
end
|
41
41
|
|
42
42
|
assert_file "app/views/notifier/bar.text.slim" do |view|
|
43
43
|
assert_match %r(app/views/notifier/bar\.text\.slim), view
|
44
|
-
assert_match
|
44
|
+
assert_match(/@greeting/, view)
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
@@ -0,0 +1,32 @@
|
|
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
|
15
|
+
end
|
16
|
+
DummyApp.initialize!
|
17
|
+
#{code}
|
18
|
+
APP
|
19
|
+
|
20
|
+
asset_path = File.join(dir, 'app', 'assets', 'html', 'test.slim')
|
21
|
+
FileUtils.mkdir_p(File.dirname(asset_path))
|
22
|
+
File.write(asset_path, ".test\n | hi")
|
23
|
+
|
24
|
+
`BUNDLE_GEMFILE=#{ENV['BUNDLE_GEMFILE']} bundle exec ruby #{app_path}`
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
test 'compile slim view' do
|
29
|
+
assert_equal 'ok', with_app(false, 'print DummyApp.assets || "ok"')
|
30
|
+
assert_equal '<div class="test">hi</div>', with_app(true, 'print DummyApp.assets["test.slim"].to_s')
|
31
|
+
end
|
32
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'minitest/autorun'
|
3
|
-
require 'rails
|
3
|
+
require 'rails'
|
4
|
+
require 'rails/test_help'
|
4
5
|
require 'rails/generators'
|
5
6
|
require 'rails/generators/test_case'
|
7
|
+
require 'slim-rails'
|
6
8
|
|
7
9
|
class TestApp < Rails::Application
|
8
10
|
config.root = File.dirname(__FILE__)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slim-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leonardo Almeida
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: sprockets-rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: rocco
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -155,6 +169,7 @@ files:
|
|
155
169
|
- lib/generators/slim/scaffold/templates/new.html.slim
|
156
170
|
- lib/generators/slim/scaffold/templates/show.html.slim
|
157
171
|
- lib/slim-rails.rb
|
172
|
+
- lib/slim-rails/register_engine.rb
|
158
173
|
- lib/slim-rails/version.rb
|
159
174
|
- slim-rails.gemspec
|
160
175
|
- test/fixtures/routes.rb
|
@@ -162,6 +177,7 @@ files:
|
|
162
177
|
- test/lib/generators/slim/mailer_generator_test.rb
|
163
178
|
- test/lib/generators/slim/scaffold_generator_test.rb
|
164
179
|
- test/lib/generators/slim/testing_helper.rb
|
180
|
+
- test/lib/slim-rails_assets_test.rb
|
165
181
|
- test/test_helper.rb
|
166
182
|
homepage: https://github.com/slim-template/slim-rails
|
167
183
|
licenses:
|
@@ -193,4 +209,5 @@ test_files:
|
|
193
209
|
- test/lib/generators/slim/mailer_generator_test.rb
|
194
210
|
- test/lib/generators/slim/scaffold_generator_test.rb
|
195
211
|
- test/lib/generators/slim/testing_helper.rb
|
212
|
+
- test/lib/slim-rails_assets_test.rb
|
196
213
|
- test/test_helper.rb
|