vue_on_rails 0.9.6 → 0.9.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -6
- data/lib/vue_on_rails/version.rb +1 -1
- data/vendor/assets/javascripts/vue_on_rails.js +11 -16
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ef2c61db2d72d94af6a9bd6d09a77d4e99eb047
|
4
|
+
data.tar.gz: 89f9d4529e962d23bf154cc6b8b53661271a4b93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8c06cafd04674c74f8c3c151e8eb0ad8dbb98cf2589d7a6c26e84ae7bd5849e8c7ccfe5c321157e48755547bd0f011d8bcbba6862c4d1a0cc6e108490be91b6
|
7
|
+
data.tar.gz: 11ce139ddfe0e735b02723645f57a95e8cd798db9dc6c30aad44d29149f371727087ef229f9b13c0f51a74e3c64cec8fd4c21bf2bd4a7f7df6a5427bd170475f
|
data/README.md
CHANGED
@@ -2,10 +2,9 @@
|
|
2
2
|
|
3
3
|
Easy and simple way to use Vue.js with Ruby on Rails and Turbolinks 5.
|
4
4
|
|
5
|
-
This gem is intended to sprinkle your Rails app with Vue components.
|
6
|
-
It's compatible with Turbolinks caching system.
|
5
|
+
This gem is intended to sprinkle your Rails app with Vue components. Really lightweight script (1.3KB minified) that mount and destroy Vue components on demand. It's works nicely with Turbolinks rendering and caching system.
|
7
6
|
|
8
|
-
If you are building a pure SPA app with Vue and Rails without Turbolinks,
|
7
|
+
If you are building a pure SPA app with Vue and Rails without Turbolinks, you will be better off looking into:
|
9
8
|
https://github.com/adambutler/vuejs-rails
|
10
9
|
|
11
10
|
## Requirements
|
@@ -37,15 +36,15 @@ Require vue_on_rails in application.js
|
|
37
36
|
//= require vue_on_rails
|
38
37
|
```
|
39
38
|
|
40
|
-
|
39
|
+
Mount and destroy Vue components:
|
41
40
|
```
|
42
41
|
# Mount Vue components
|
43
42
|
document.addEventListener 'turbolinks:load', ->
|
44
|
-
VueOnRails.
|
43
|
+
VueOnRails.mountComponents()
|
45
44
|
|
46
45
|
# Destroy Vue components
|
47
46
|
document.addEventListener 'turbolinks:before-render', ->
|
48
|
-
VueOnRails.
|
47
|
+
VueOnRails.destroyComponents()
|
49
48
|
```
|
50
49
|
|
51
50
|
Example Vue component in my_component.coffee
|
data/lib/vue_on_rails/version.rb
CHANGED
@@ -22,28 +22,23 @@ this.VueOnRails = (function() {
|
|
22
22
|
name = component.getAttribute('data-vue-component');
|
23
23
|
props = JSON.parse(component.getAttribute('data-vue-props'));
|
24
24
|
if ((namespace && typeof window[namespace][name] === 'object') || window[name] === 'object') {
|
25
|
-
|
26
|
-
component.innerHTML = '';
|
27
|
-
component.appendChild(el);
|
28
|
-
vm = newVueInstance(name, props, el);
|
25
|
+
vm = newVueInstance(name, props, component);
|
29
26
|
return vueModels.push(vm);
|
30
27
|
}
|
31
28
|
};
|
32
29
|
|
33
|
-
newVueInstance = function(name, props,
|
34
|
-
var
|
35
|
-
|
36
|
-
|
30
|
+
newVueInstance = function(name, props, component) {
|
31
|
+
var nameFormatted = camelCaseToHyphen(name);
|
32
|
+
var element = document.createElement(nameFormatted);
|
33
|
+
var componentName = namespace ? window[namespace][name] : window[name];
|
37
34
|
setElementProps(element, props);
|
38
|
-
component =
|
35
|
+
component.innerHTML = '';
|
36
|
+
component.appendChild(element);
|
37
|
+
componentObj = {};
|
38
|
+
componentObj[nameFormatted] = componentName;
|
39
39
|
return new Vue({
|
40
|
-
el:
|
41
|
-
|
42
|
-
components: (
|
43
|
-
obj = {},
|
44
|
-
obj["" + nameFormatted] = component,
|
45
|
-
obj
|
46
|
-
)
|
40
|
+
el: component,
|
41
|
+
components: componentObj
|
47
42
|
});
|
48
43
|
};
|
49
44
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vue_on_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benoit Zeler
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -96,5 +96,6 @@ rubyforge_project:
|
|
96
96
|
rubygems_version: 2.6.11
|
97
97
|
signing_key:
|
98
98
|
specification_version: 4
|
99
|
-
summary: Easy and simple way to
|
99
|
+
summary: Easy and simple way to mount/destroy Vue.js components with Ruby on Rails
|
100
|
+
and Turbolinks 5.
|
100
101
|
test_files: []
|