slim_assets 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.ruby-version +1 -0
- data/.travis.yml +2 -2
- data/README.md +2 -6
- data/lib/slim_assets/engine.rb +12 -3
- data/lib/slim_assets/slim_sprockets_engine.rb +17 -22
- data/lib/slim_assets/version.rb +1 -1
- data/slim_assets.gemspec +2 -2
- data/spec/rails_app/config/application.rb +0 -1
- data/spec/render_spec.rb +3 -2
- data/spec/spec_helper.rb +3 -1
- metadata +70 -53
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3dc5349ebeafd4d6e1c87392155d24d84b7e0c08
|
4
|
+
data.tar.gz: d6dc49900768a58a26f06639208e02b5b0da763a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 30cd00d673442a5da5d18c14476bac4a0542fab24e75682ee4b8f899a8180dda9daff547b6237818e9546dd10f674c63ee9b4c32e607a70d284cf11aba0f3905
|
7
|
+
data.tar.gz: 00ba36e407ebd5e02ca1a189d2763bddf212034002b8b558118c7c9329cbb004d9dccb35deeebc478c9dbf1582569a964c6456d98e49edbce504dbb419265eb7
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.10
|
data/.travis.yml
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
rvm:
|
2
|
-
-
|
3
|
-
- 1
|
2
|
+
- 2.0
|
3
|
+
- 2.1
|
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
*ALPHA*
|
4
4
|
|
5
|
+
[![Build Status](https://secure.travis-ci.org/dabit/slim_assets.png)](http://travis-ci.org/dabit/slim_assets)
|
6
|
+
|
5
7
|
Writing Javascript templates for Backbone.js (or other frameworks) in your app? Would you like to use slim and the asset pipeline?
|
6
8
|
|
7
9
|
This gem adds slim templating support to the Rails 3.1 asset pipeline. This gem works with the EJS gem and JST asset engine to make your slim available as a compiled Javascript template.
|
@@ -16,7 +18,6 @@ Add this to your `Gemfile`
|
|
16
18
|
|
17
19
|
# Using slim for your Javascript templates
|
18
20
|
|
19
|
-
|
20
21
|
## Templates directory
|
21
22
|
|
22
23
|
You should locate your templates under `app/assets`; we suggest `app/assets/templates`. In your Javascript manifest file (for example `application.js`), use `require_tree`
|
@@ -59,8 +60,3 @@ All the ActionView and route helpers are available in your template. If you use
|
|
59
60
|
|
60
61
|
This gem is heavily based on their [haml_assets gem](https://github.com/infbio/haml_assets)
|
61
62
|
|
62
|
-
# About the Author
|
63
|
-
|
64
|
-
[Crowd Interactive](http://www.crowdint.com) is a web design and development company that happens to work in Colima, Mexico.
|
65
|
-
We specialize in building and growing online retail stores. We don’t work with everyone – just companies we believe in. Call us today to see if there’s a fit.
|
66
|
-
Find more info [here](http://www.crowdint.com)!
|
data/lib/slim_assets/engine.rb
CHANGED
@@ -1,9 +1,18 @@
|
|
1
1
|
module SlimAssets
|
2
2
|
class Engine < ::Rails::Engine
|
3
|
-
initializer
|
4
|
-
|
3
|
+
initializer 'slim_assets.assets.register', :group => :all do |app|
|
4
|
+
app.config.assets.configure do |sprockets_env|
|
5
|
+
if sprockets_env.respond_to?(:register_transformer)
|
6
|
+
sprockets_env.register_mime_type 'application/vnd.slim-template.slim+text', extensions: ['.slim']
|
7
|
+
sprockets_env.register_transformer 'application/vnd.slim-template.slim+text', 'application/javascript', SlimSprocketsEngine
|
8
|
+
end
|
5
9
|
|
6
|
-
|
10
|
+
if sprockets_env.respond_to?(:register_engine)
|
11
|
+
args = ['.slim', SlimSprocketsEngine]
|
12
|
+
args << { silence_deprecation: true } if Sprockets::VERSION.start_with?('3')
|
13
|
+
sprockets_env.register_engine(*args)
|
14
|
+
end
|
15
|
+
end
|
7
16
|
end
|
8
17
|
end
|
9
18
|
end
|
@@ -3,9 +3,7 @@ require 'tilt'
|
|
3
3
|
|
4
4
|
module SlimAssets
|
5
5
|
class SlimSprocketsEngine < Tilt::Template
|
6
|
-
|
7
|
-
'application/javascript'
|
8
|
-
end
|
6
|
+
self.default_mime_type = 'application/javascript'
|
9
7
|
|
10
8
|
module ViewContext
|
11
9
|
attr_accessor :output_buffer
|
@@ -15,6 +13,7 @@ module SlimAssets
|
|
15
13
|
include Rails.application.routes.url_helpers
|
16
14
|
include Rails.application.routes.mounted_helpers
|
17
15
|
include ActionView::Helpers
|
16
|
+
include SimpleForm::ActionViewExtensions::FormHelper if defined?(SimpleForm)
|
18
17
|
end
|
19
18
|
end
|
20
19
|
|
@@ -23,13 +22,19 @@ module SlimAssets
|
|
23
22
|
end
|
24
23
|
end
|
25
24
|
|
25
|
+
def prepare
|
26
|
+
# options = @options.merge(:filename => eval_file, :line => line)
|
27
|
+
@engine = ::Slim::Engine.new(options)
|
28
|
+
end
|
29
|
+
|
26
30
|
def evaluate(scope, locals, &block)
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
31
|
+
scope = view_context(scope)
|
32
|
+
|
33
|
+
super
|
34
|
+
end
|
35
|
+
|
36
|
+
def precompiled_template(locals)
|
37
|
+
@engine.call(data.to_str)
|
33
38
|
end
|
34
39
|
|
35
40
|
protected
|
@@ -38,20 +43,10 @@ module SlimAssets
|
|
38
43
|
@context_class ||= Class.new(scope.environment.context_class)
|
39
44
|
end
|
40
45
|
|
41
|
-
def prepare; end
|
42
|
-
|
43
|
-
def render_slim(context, locals)
|
44
|
-
Slim::Template.new(generator: Temple::Generators::RailsOutputBuffer) {|t| data }.render(context)
|
45
|
-
end
|
46
|
-
|
47
|
-
# The Sprockets context is shared among all the processors, give Slim its
|
48
|
-
# own context
|
49
46
|
def view_context(scope)
|
50
|
-
@view_context ||=
|
51
|
-
|
52
|
-
|
53
|
-
scope.logical_path.to_s,
|
54
|
-
scope.pathname).tap { |ctx| ctx.class.send(:include, ViewContext) }
|
47
|
+
@view_context ||= scope.tap do |s|
|
48
|
+
s.singleton_class.instance_eval { include SlimAssets::SlimSprocketsEngine::ViewContext }
|
49
|
+
end
|
55
50
|
end
|
56
51
|
end
|
57
52
|
end
|
data/lib/slim_assets/version.rb
CHANGED
data/slim_assets.gemspec
CHANGED
@@ -6,8 +6,8 @@ Gem::Specification.new do |s|
|
|
6
6
|
s.name = "slim_assets"
|
7
7
|
s.version = SlimAssets::VERSION
|
8
8
|
s.authors = ["David Padilla"]
|
9
|
-
s.email = ["david@
|
10
|
-
s.homepage = ""
|
9
|
+
s.email = ["david@padilla.cc"]
|
10
|
+
s.homepage = "https://github.com/dabit/slim_assets"
|
11
11
|
s.summary = %q{Use Slim with Rails helpers in the asset pipeline}
|
12
12
|
s.description = %q{Use Slim with Rails helpers in the asset pipeline}
|
13
13
|
|
data/spec/render_spec.rb
CHANGED
@@ -5,10 +5,11 @@ end
|
|
5
5
|
|
6
6
|
describe SlimAssets do
|
7
7
|
it "should have the proper format" do
|
8
|
-
RailsApp::Application.assets['link_to.jst.ejs.slim']
|
8
|
+
print RailsApp::Application.assets['link_to.jst.ejs.slim']
|
9
|
+
RailsApp::Application.assets['link_to.jst.ejs.slim'].to_s.should eq "(function() {\n this.JST || (this.JST = {});\n this.JST[\"link_to\"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('h1\\n .text Render works\\n\\n');}return __p.join('');};\n}).call(this);\n"
|
9
10
|
end
|
10
11
|
|
11
12
|
it "should use rails helpers" do
|
12
|
-
RailsApp::Application.assets['helpers.jst.ejs.slim'].to_s.should == "(function() {\n this.JST || (this.JST = {});\n this.JST[\"helpers\"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('
|
13
|
+
RailsApp::Application.assets['helpers.jst.ejs.slim'].to_s.should == "(function() {\n this.JST || (this.JST = {});\n this.JST[\"helpers\"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('h1 Form\\n= form_for Post.new, url: \\'/\\' do |f|\\n = f.text_field :title\\n');}return __p.join('');};\n}).call(this);\n"
|
13
14
|
end
|
14
15
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -2,6 +2,9 @@ ENV["RAILS_ENV"] = "test"
|
|
2
2
|
|
3
3
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
4
4
|
|
5
|
+
require 'fileutils'
|
6
|
+
FileUtils.mkdir_p("./spec/rails_app/tmp/cache/")
|
7
|
+
|
5
8
|
require 'rails_app/config/environment'
|
6
9
|
require 'slim_assets'
|
7
10
|
require 'ejs'
|
@@ -19,4 +22,3 @@ ActiveRecord::Schema.define(:version => 0) do
|
|
19
22
|
end
|
20
23
|
end
|
21
24
|
|
22
|
-
|
metadata
CHANGED
@@ -1,115 +1,139 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slim_assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.3
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- David Padilla
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2017-01-25 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: slim
|
16
|
-
requirement:
|
17
|
-
none: false
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
25
27
|
- !ruby/object:Gem::Dependency
|
26
28
|
name: tilt
|
27
|
-
requirement:
|
28
|
-
none: false
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
29
30
|
requirements:
|
30
|
-
- -
|
31
|
+
- - ">="
|
31
32
|
- !ruby/object:Gem::Version
|
32
33
|
version: '0'
|
33
34
|
type: :runtime
|
34
35
|
prerelease: false
|
35
|
-
version_requirements:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
36
41
|
- !ruby/object:Gem::Dependency
|
37
42
|
name: rails
|
38
|
-
requirement:
|
39
|
-
none: false
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
40
44
|
requirements:
|
41
|
-
- - ~>
|
45
|
+
- - "~>"
|
42
46
|
- !ruby/object:Gem::Version
|
43
47
|
version: 3.1.0
|
44
48
|
type: :development
|
45
49
|
prerelease: false
|
46
|
-
version_requirements:
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.1.0
|
47
55
|
- !ruby/object:Gem::Dependency
|
48
56
|
name: sqlite3
|
49
|
-
requirement:
|
50
|
-
none: false
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
51
58
|
requirements:
|
52
|
-
- -
|
59
|
+
- - ">="
|
53
60
|
- !ruby/object:Gem::Version
|
54
61
|
version: '0'
|
55
62
|
type: :development
|
56
63
|
prerelease: false
|
57
|
-
version_requirements:
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
58
69
|
- !ruby/object:Gem::Dependency
|
59
70
|
name: rspec
|
60
|
-
requirement:
|
61
|
-
none: false
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
62
72
|
requirements:
|
63
|
-
- -
|
73
|
+
- - ">="
|
64
74
|
- !ruby/object:Gem::Version
|
65
75
|
version: '0'
|
66
76
|
type: :development
|
67
77
|
prerelease: false
|
68
|
-
version_requirements:
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: rspec-rails
|
71
|
-
requirement:
|
72
|
-
none: false
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
73
86
|
requirements:
|
74
|
-
- -
|
87
|
+
- - ">="
|
75
88
|
- !ruby/object:Gem::Version
|
76
89
|
version: '0'
|
77
90
|
type: :development
|
78
91
|
prerelease: false
|
79
|
-
version_requirements:
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
80
97
|
- !ruby/object:Gem::Dependency
|
81
98
|
name: ejs
|
82
|
-
requirement:
|
83
|
-
none: false
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
84
100
|
requirements:
|
85
|
-
- -
|
101
|
+
- - ">="
|
86
102
|
- !ruby/object:Gem::Version
|
87
103
|
version: '0'
|
88
104
|
type: :development
|
89
105
|
prerelease: false
|
90
|
-
version_requirements:
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
91
111
|
- !ruby/object:Gem::Dependency
|
92
112
|
name: psych
|
93
|
-
requirement:
|
94
|
-
none: false
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
95
114
|
requirements:
|
96
|
-
- -
|
115
|
+
- - ">="
|
97
116
|
- !ruby/object:Gem::Version
|
98
117
|
version: '0'
|
99
118
|
type: :development
|
100
119
|
prerelease: false
|
101
|
-
version_requirements:
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
102
125
|
description: Use Slim with Rails helpers in the asset pipeline
|
103
126
|
email:
|
104
|
-
- david@
|
127
|
+
- david@padilla.cc
|
105
128
|
executables: []
|
106
129
|
extensions: []
|
107
130
|
extra_rdoc_files: []
|
108
131
|
files:
|
109
|
-
- .gitignore
|
110
|
-
- .rspec
|
111
|
-
- .
|
112
|
-
- .
|
132
|
+
- ".gitignore"
|
133
|
+
- ".rspec"
|
134
|
+
- ".ruby-version"
|
135
|
+
- ".rvmrc"
|
136
|
+
- ".travis.yml"
|
113
137
|
- Gemfile
|
114
138
|
- README.md
|
115
139
|
- Rakefile
|
@@ -136,35 +160,28 @@ files:
|
|
136
160
|
- spec/rails_app/script/rails
|
137
161
|
- spec/render_spec.rb
|
138
162
|
- spec/spec_helper.rb
|
139
|
-
homepage:
|
163
|
+
homepage: https://github.com/dabit/slim_assets
|
140
164
|
licenses: []
|
165
|
+
metadata: {}
|
141
166
|
post_install_message:
|
142
167
|
rdoc_options: []
|
143
168
|
require_paths:
|
144
169
|
- lib
|
145
170
|
required_ruby_version: !ruby/object:Gem::Requirement
|
146
|
-
none: false
|
147
171
|
requirements:
|
148
|
-
- -
|
172
|
+
- - ">="
|
149
173
|
- !ruby/object:Gem::Version
|
150
174
|
version: '0'
|
151
|
-
segments:
|
152
|
-
- 0
|
153
|
-
hash: 1527951104491763291
|
154
175
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
155
|
-
none: false
|
156
176
|
requirements:
|
157
|
-
- -
|
177
|
+
- - ">="
|
158
178
|
- !ruby/object:Gem::Version
|
159
179
|
version: '0'
|
160
|
-
segments:
|
161
|
-
- 0
|
162
|
-
hash: 1527951104491763291
|
163
180
|
requirements: []
|
164
181
|
rubyforge_project: slim_assets
|
165
|
-
rubygems_version:
|
182
|
+
rubygems_version: 2.2.5
|
166
183
|
signing_key:
|
167
|
-
specification_version:
|
184
|
+
specification_version: 4
|
168
185
|
summary: Use Slim with Rails helpers in the asset pipeline
|
169
186
|
test_files:
|
170
187
|
- spec/rails_app/.gitignore
|