sprockets-vue 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +40 -0
- data/lib/sprockets/vue/version.rb +5 -0
- data/lib/sprockets/vue.rb +48 -0
- metadata +90 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a27adbb7278c5ec914d1ed7d0795f3b0b8eddd55
|
4
|
+
data.tar.gz: 8129c4f62ed189c78ffe3f516f0d9668398e76cf
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d625dd158eb2d39c818900a3a5fafd1cf341ca35dfd33a652d3c8ff4dfb04de8dfc4dcbc505ddecf91d8818ec43799f68b6640fa3d7e586e1ce82a72a607f3e6
|
7
|
+
data.tar.gz: a4bfcf11778396576a42dc4f00ae9539c1ea1770f8f46b8e04eb63fd4b20b4fded55da7f6045e992ac9ca86dd4172e2f21ab075448fcb07e95ca6b1c6433cffd
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2016 Kikyous
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# sprockets-vue
|
2
|
+
A Sprockets transformer that converts .vue file into js object.
|
3
|
+
|
4
|
+
* index.vue
|
5
|
+
```vue
|
6
|
+
|
7
|
+
<script lang="coffee">
|
8
|
+
{
|
9
|
+
data: ->
|
10
|
+
members: []
|
11
|
+
methods:
|
12
|
+
clear: ->
|
13
|
+
this.search = ''
|
14
|
+
}
|
15
|
+
</script>
|
16
|
+
|
17
|
+
<template>
|
18
|
+
<div class="container">
|
19
|
+
<div class='search icon-input'>
|
20
|
+
<span class="search-icon glyphicon glyphicon-search"></span>
|
21
|
+
<input class="form-control" type="text" v-model='search'>
|
22
|
+
<span @click='clear' class="clear-icon glyphicon glyphicon-remove"></span>
|
23
|
+
</div>
|
24
|
+
<card v-for="m in members" :m='m'></card>
|
25
|
+
</div>
|
26
|
+
</template>
|
27
|
+
```
|
28
|
+
|
29
|
+
* application.coffee
|
30
|
+
|
31
|
+
```coffee
|
32
|
+
#= require ./index
|
33
|
+
|
34
|
+
new Vue(
|
35
|
+
el: '#search',
|
36
|
+
components: {
|
37
|
+
'index': VCompents['index']
|
38
|
+
}
|
39
|
+
)
|
40
|
+
```
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'sprockets'
|
2
|
+
require 'sprockets/vue/version'
|
3
|
+
|
4
|
+
module Sprockets
|
5
|
+
class Vue
|
6
|
+
class << self
|
7
|
+
include ActionView::Helpers::JavaScriptHelper
|
8
|
+
SCRIPT_COMPILES = {
|
9
|
+
'coffee' => ->(s, input){
|
10
|
+
CoffeeScript.compile(s, sourceMap: true, sourceFiles: [input[:source_path]], no_wrap: true)
|
11
|
+
},
|
12
|
+
'es6' => ->(s, input){
|
13
|
+
Babel::Transpiler.transform(data, {}) #TODO
|
14
|
+
}
|
15
|
+
}
|
16
|
+
def call(input)
|
17
|
+
data = input[:data]
|
18
|
+
name = input[:name]
|
19
|
+
input[:cache].fetch([cache_key, input[:filename], data]) do
|
20
|
+
script_r = /\<script *(lang="(\w+)")?\>([\s\S]+)\<\/script\>/
|
21
|
+
template_r = /\<template\>([\s\S]+)\<\/template\>/
|
22
|
+
script = script_r.match(data)
|
23
|
+
lang = script[2]
|
24
|
+
template = template_r.match(data)
|
25
|
+
|
26
|
+
result = SCRIPT_COMPILES[lang].call(script[3], input)
|
27
|
+
|
28
|
+
output = ";if (typeof(VCompents)==='undefined')VCompents = {};
|
29
|
+
VCompents['#{name}'] = #{result['js']};"
|
30
|
+
output << "VCompents['#{name}'].template = '#{escape_javascript template[1]}';" if template
|
31
|
+
|
32
|
+
{ data: output }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def cache_key
|
37
|
+
[
|
38
|
+
self.name,
|
39
|
+
VERSION,
|
40
|
+
].freeze
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
if respond_to?(:register_transformer)
|
45
|
+
register_mime_type 'text/vue', extensions: ['.vue'], charset: :unicode
|
46
|
+
register_transformer 'text/vue', 'application/javascript', Vue
|
47
|
+
end
|
48
|
+
end
|
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sprockets-vue
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- kikyous
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-10-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sprockets
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: " A Sprockets transformer that converts .vue file into
|
56
|
+
js object.\n"
|
57
|
+
email: kikyous@163.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- MIT-LICENSE
|
63
|
+
- README.md
|
64
|
+
- lib/sprockets/vue.rb
|
65
|
+
- lib/sprockets/vue/version.rb
|
66
|
+
homepage: https://github.com/TannerRogalsky/sprockets-es6
|
67
|
+
licenses:
|
68
|
+
- MIT
|
69
|
+
metadata: {}
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options: []
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
requirements: []
|
85
|
+
rubyforge_project:
|
86
|
+
rubygems_version: 2.5.1
|
87
|
+
signing_key:
|
88
|
+
specification_version: 4
|
89
|
+
summary: Sprockets Vue transformer
|
90
|
+
test_files: []
|