File tree Expand file tree Collapse file tree 5 files changed +50
-3
lines changed
lib/generators/inertia_rails Expand file tree Collapse file tree 5 files changed +50
-3
lines changed File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <h1 :style =" { 'text-align': 'center' }" >Hello {{name}}!</h1 >
3
+ </template >
4
+
5
+ <script >
6
+ export default {
7
+ props: {
8
+ name: { type: String , required: true },
9
+ },
10
+ }
11
+ </script >
Original file line number Diff line number Diff line change
1
+ import axios from 'axios'
2
+ import Vue from 'vue'
3
+
4
+ import { app , plugin } from '@inertiajs/inertia-vue'
5
+ import { InertiaProgress } from '@inertiajs/progress'
6
+
7
+ document . addEventListener ( 'DOMContentLoaded' , ( ) => {
8
+ const csrfToken = document . querySelector ( 'meta[name=csrf-token]' ) . content
9
+ axios . defaults . headers . common [ 'X-CSRF-Token' ] = csrfToken
10
+
11
+ InertiaProgress . init ( ) ;
12
+ const el = document . getElementById ( 'app' )
13
+
14
+ Vue . use ( plugin )
15
+
16
+ new Vue ( {
17
+ render : h => h ( app , {
18
+ props : {
19
+ initialPage : JSON . parse ( el . dataset . page ) ,
20
+ resolveComponent : name => require ( `../Pages/${ name } ` ) . default ,
21
+ } ,
22
+ } ) ,
23
+ } ) . $mount ( el )
24
+ } )
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ class InstallGenerator < Rails::Generators::Base
5
5
6
6
FRONT_END_INSTALLERS = [
7
7
'react' ,
8
+ 'vue' ,
8
9
]
9
10
10
11
def install
@@ -32,6 +33,8 @@ def installable?
32
33
33
34
return false
34
35
end
36
+
37
+ true
35
38
end
36
39
37
40
def install_base!
@@ -53,10 +56,19 @@ def install_base!
53
56
def install_react!
54
57
say "Creating a React page component..." , :blue
55
58
run 'yarn add @inertiajs/inertia-react'
56
- template "react.jsx" , Rails . root . join ( "app/javascript/Pages/InertiaExample.js" ) . to_s
59
+ template "react/InertiaExample .jsx" , Rails . root . join ( "app/javascript/Pages/InertiaExample.js" ) . to_s
57
60
say "Copying inertia.jsx into webpacker's packs folder..." , :blue
58
- template "inertia.jsx" , Rails . root . join ( "app/javascript/packs/inertia.jsx" ) . to_s
61
+ template "react/inertia.jsx" , Rails . root . join ( "app/javascript/packs/inertia.jsx" ) . to_s
62
+ say "done!" , :green
63
+ end
64
+
65
+ def install_vue!
66
+ say "Creating a Vue page component..." , :blue
67
+ run 'yarn add @inertiajs/inertia-vue'
68
+ template "vue/InertiaExample.vue" , Rails . root . join ( "app/javascript/Pages/InertiaExample.vue" ) . to_s
69
+ say "Copying inertia.js into webpacker's packs folder..." , :blue
70
+ template "vue/inertia.js" , Rails . root . join ( "app/javascript/packs/inertia.js" ) . to_s
59
71
say "done!" , :green
60
72
end
61
73
end
62
- end
74
+ end
You can’t perform that action at this time.
0 commit comments