es6-rails 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/es6-rails.gemspec +27 -0
- data/lib/es6-rails.rb +6 -0
- data/lib/es6/rails/inline_handler.rb +15 -0
- data/lib/es6/rails/template_handler.rb +18 -0
- data/lib/es6/rails/version.rb +5 -0
- metadata +131 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 766769a31479b0d52f91af53b238b39d4c255f48
|
4
|
+
data.tar.gz: b136a4c79116039edf0664ae6d0f7d12e2b6a4d3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3bda84f11b076f06a2833ff6ee777a72933a1705fad0531d35f9d2fbdef1632df68050be6c437689c1a6abbc08b58831b65902df4a8ed00c7679c4a2e60a73c4
|
7
|
+
data.tar.gz: dbd5530f20624276d7bd9f21dba7d5ccd863cef31a8cac23a291c1cd68be0c0f071093197194d57e7a39af0e385e67809a80bd00f59742091c3dc479c99baace
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*.gem
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Cristian Dugacicu
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# ES6-Rails with Babel
|
2
|
+
ES6 (EcmaScript 6) adapter for Rails. Use ES6 in the assets, view files and inline.
|
3
|
+
|
4
|
+
## Use
|
5
|
+
Asset pipeline:
|
6
|
+
- add ES6 code in `.es6` files
|
7
|
+
|
8
|
+
Views:
|
9
|
+
- add ES6 code in `.es6` files.
|
10
|
+
- also use ERB code in the `.es6` file
|
11
|
+
|
12
|
+
Inline:
|
13
|
+
- use with: `<%= es6_transform do %> .. es6 code .. <% end %>`
|
14
|
+
E.g.:
|
15
|
+
```
|
16
|
+
<script>
|
17
|
+
<%= es6_transform do %>
|
18
|
+
let square = x => x * x;
|
19
|
+
console.log(square(5));
|
20
|
+
<% end %>
|
21
|
+
</script>
|
22
|
+
```
|
23
|
+
|
24
|
+
## Installation
|
25
|
+
Add the es6-rails to your Gemfile:
|
26
|
+
|
27
|
+
~~~ruby
|
28
|
+
gem 'es6-rails'
|
29
|
+
~~~
|
data/es6-rails.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "es6/rails/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'es6-rails'
|
7
|
+
s.version = Es6::Rails::VERSION
|
8
|
+
s.date = '2015-10-19'
|
9
|
+
s.summary = "ES6 adapter for Rails"
|
10
|
+
s.description = "Enables use of ES6 in assets, views and inline."
|
11
|
+
s.files = `git ls-files`.split($/)
|
12
|
+
'http://rubygems.org'
|
13
|
+
s.license = 'MIT'
|
14
|
+
|
15
|
+
s.require_paths = ["lib"]
|
16
|
+
s.required_ruby_version = '>= 2.0.0'
|
17
|
+
|
18
|
+
s.add_dependency 'rails', '>= 4.0', '< 5.0'
|
19
|
+
s.add_dependency 'babel-transpiler', '~> 0.7', '>= 0.7.0'
|
20
|
+
s.add_dependency 'sprockets', '~> 3.0', '>= 3.0.0'
|
21
|
+
s.add_dependency 'sprockets-es6', '~> 0.8', '>= 0.8.1'
|
22
|
+
|
23
|
+
s.authors = ["Cristian Dugacicu"]
|
24
|
+
s.homepage = ""
|
25
|
+
s.email = 'razorcd@yahoo.com'
|
26
|
+
end
|
27
|
+
|
data/lib/es6-rails.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
module Es6
|
2
|
+
module Rails
|
3
|
+
module ViewHelpers
|
4
|
+
def es6_transform(es6_code = nil, &block)
|
5
|
+
es6_code ||= capture(&block)
|
6
|
+
js_code = Babel::Transpiler.transform(es6_code)["code"]
|
7
|
+
js_code.html_safe #js code
|
8
|
+
# javascript_tag js_code # adds <script> tags to generated js code
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
ActiveSupport.on_load( :action_view ){ include Es6::Rails::ViewHelpers }
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Es6
|
2
|
+
module Rails
|
3
|
+
class TemplateHandler
|
4
|
+
def self.erb_handler
|
5
|
+
@@erb_handler ||= ActionView::Template.registered_template_handler(:erb)
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.call(template)
|
9
|
+
compiled_source = erb_handler.call(template)
|
10
|
+
"Babel::Transpiler.transform(begin;#{compiled_source};end)['code'].html_safe"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
ActiveSupport.on_load(:action_view) do
|
17
|
+
ActionView::Template.register_template_handler :es6, Es6::Rails::TemplateHandler
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: es6-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Cristian Dugacicu
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-10-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.0'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '5.0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '4.0'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '5.0'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: babel-transpiler
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0.7'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 0.7.0
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0.7'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 0.7.0
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: sprockets
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '3.0'
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 3.0.0
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '3.0'
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 3.0.0
|
73
|
+
- !ruby/object:Gem::Dependency
|
74
|
+
name: sprockets-es6
|
75
|
+
requirement: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - "~>"
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0.8'
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.8.1
|
83
|
+
type: :runtime
|
84
|
+
prerelease: false
|
85
|
+
version_requirements: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.8'
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: 0.8.1
|
93
|
+
description: Enables use of ES6 in assets, views and inline.
|
94
|
+
email: razorcd@yahoo.com
|
95
|
+
executables: []
|
96
|
+
extensions: []
|
97
|
+
extra_rdoc_files: []
|
98
|
+
files:
|
99
|
+
- ".gitignore"
|
100
|
+
- LICENSE.txt
|
101
|
+
- README.md
|
102
|
+
- es6-rails.gemspec
|
103
|
+
- lib/es6-rails.rb
|
104
|
+
- lib/es6/rails/inline_handler.rb
|
105
|
+
- lib/es6/rails/template_handler.rb
|
106
|
+
- lib/es6/rails/version.rb
|
107
|
+
homepage: ''
|
108
|
+
licenses:
|
109
|
+
- MIT
|
110
|
+
metadata: {}
|
111
|
+
post_install_message:
|
112
|
+
rdoc_options: []
|
113
|
+
require_paths:
|
114
|
+
- lib
|
115
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: 2.0.0
|
120
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
requirements: []
|
126
|
+
rubyforge_project:
|
127
|
+
rubygems_version: 2.4.6
|
128
|
+
signing_key:
|
129
|
+
specification_version: 4
|
130
|
+
summary: ES6 adapter for Rails
|
131
|
+
test_files: []
|