File tree Expand file tree Collapse file tree 9 files changed +87
-7
lines changed
Expand file tree Collapse file tree 9 files changed +87
-7
lines changed Original file line number Diff line number Diff line change 1- # vue-script-parser
1+ # vue-script-parser
2+
3+ This package can be used to parse vue script section.
4+
5+
6+ ## Installation
7+
8+ ```
9+ npm install vue-script-ast-parser
10+ ```
11+
12+
13+ ## Usage
14+
15+ ```
16+ <script>
17+
18+ import parser from 'vue-script-ast-parser';
19+
20+ export default {
21+ data() {
22+ return {}
23+ },
24+ methods: {
25+ parseCode() {
26+ let code = `
27+ import Vue from 'vue
28+ import myComponent from 'myComponent'
29+ export default {
30+ data() {
31+ return {
32+ name: 'Kunal'
33+ }
34+ },
35+ methods: {
36+ test() {
37+ console.log('this is test method')
38+ },
39+ },
40+ }`
41+ let instance = new VueScriptParser(code)
42+ console.log(instance)
43+ }
44+ }
45+ }
46+
47+ </script>
48+ ```
49+
50+ ## Output
51+
52+ ```
53+ {
54+ "imports": [
55+ "import Vue from 'vue",
56+ "import myComponent from 'myComponent'"
57+ ],
58+ "data": [
59+ {
60+ "key": "name",
61+ "value": "Kunal"
62+ }
63+ ],
64+ "mounted": "\n console.log('this is mounted')\n ",
65+ "methods": [
66+ {
67+ "name": "test",
68+ "body": "\n console.log('this is test method')\n ",
69+ "arguments": [
70+ "args1",
71+ "args2"
72+ ]
73+ }
74+ ]
75+ }
76+ ```
77+
Original file line number Diff line number Diff line change 1212</template >
1313
1414<script >
15- import VueScriptParser from ' ./plugin /index'
15+ import VueScriptParser from ' .. /index'
1616export default {
1717 data () {
1818 return {
Original file line number Diff line number Diff line change 1- import Data from './data'
2- import Methods from './methods'
3- import Mounted from './mounted'
4- import Imports from './imports'
1+ import Data from './modules/data'
2+ import Methods from './modules/methods'
3+ import Mounted from './modules/mounted'
4+ import Imports from './modules/imports'
5+
56class VueScriptParser {
67 constructor ( vueScript = '' ) {
78 //load imports
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change 11{
2- "name" : " vue-script-parser" ,
2+ "name" : " vue-script-ast- parser" ,
33 "version" : " 1.0.0" ,
44 "description" : " " ,
55 "main" : " index.js" ,
1212 },
1313 "keywords" : [
1414 " vue" ,
15+ " ast" ,
16+ " vue-script-ast-parser" ,
1517 " vue-parser" ,
18+ " vue-script-parser" ,
1619 " vue-script" ,
1720 " vue" ,
1821 " script" ,
You can’t perform that action at this time.
0 commit comments