You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+13-43
Original file line number
Diff line number
Diff line change
@@ -13,51 +13,13 @@ The easiest way to install this library in your project is to use the correspond
13
13
# vue add extensions
14
14
```
15
15
16
-
#### Manual install
16
+
This adds everything you need automatically to your project. Just make sure that `runtimeCompiler: true` is enabled in `vue.config.js` - to use template strings in Vue.
17
17
18
-
You can do everything manually too, if you want:
19
-
```bash
20
-
npm install vue-extensions
21
-
```
22
-
and add the following code:
23
-
24
-
Create a file, e.g. named `extensions.js`, which exports all of your extensions as default (you can e.g. automate the creation of this file in a script):
Note that you have to enable Vue's runtime compiler if you want to render single file template components as extensions!
50
-
51
-
```Javascript
52
-
// vue.config.js
53
-
module.exports= {
54
-
runtimeCompiler:true
55
-
}
56
-
```
18
+
If you choose to install everything manually, see [Manual install](manuall-install.md).
57
19
58
20
## Extensions
59
21
60
-
Easily said: Extensions are Javascript modules that export a `hooks`object, which is a named index pointing to Vue components:
22
+
Extensions are modules that export a default object with a `hooks`property, which is a named index pointing to Vue components. This seems complicated, but an example makes it much clearer:
61
23
62
24
```javascript
63
25
// extensions/FooExtension/index.js
@@ -72,18 +34,26 @@ export default {
72
34
}
73
35
```
74
36
75
-
You have an `<extensionpoint>` tag in your project available now:
37
+
One module can provide components for more than one hooks.
38
+
39
+
There is an `<extensionpoint>` tag in your project available now:
76
40
77
41
```html
78
42
<template>
43
+
<h3>Extensionpoints for "my-list-element" in a list:</h3>
79
44
<ul>
80
-
<extensionpointhook="my-list-element">
45
+
<extensionpointhook="my-list-element"/>
81
46
</ul>
47
+
48
+
<h3>Extensionpoints for "blah-another-hook"</h3>
49
+
<extensionpointhook="blah-another-hook"/>
82
50
</template>
83
51
```
84
52
85
53
The *vue-extensions* plugin renders the hooked elements replacing the <extensionpoint> element, one after another. It's up to you what the extensions are rendering: One extension can render a simple `<div>` element with an image, the next extension (same hook!) can render a complicated component with variables, sub-components etc. The `<extensionpoint>` renders them one after another. You only have to make sure that your components do what they promise: in the sample case above, `FooListElement` should render a \<li\> element - because it will be rendered within an \<ul\> element. But there are no constraints, you are free to choose.
86
54
55
+
## Further usage
56
+
The extensions.js file (or how you choose to name it) is intended to be created automatically by a script of your choice - If you want to see a project that uses this, see my [GDAPS][https://gdaps.readthedocs.io], which is a Django plugin system that can use Vue as frontend.
You can install vue-extensions manually too, if you want (instead of invoking `vue add extensions`):
4
+
5
+
```bash
6
+
npm install vue-extensions
7
+
```
8
+
and add the following code:
9
+
10
+
Create a file, e.g. named `extensions.js`, which exports all of your extensions as default (you can e.g. automate the creation of this file in a script):
0 commit comments