Skip to content

Commit 109f351

Browse files
committed
Merge branch 'main' of github.com:matestack/matestack-ui-vuejs into main
2 parents 72843fd + b7d88af commit 109f351

File tree

3 files changed

+35
-7
lines changed

3 files changed

+35
-7
lines changed

docs/custom-reactivity/custom-vue-js-components.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Custom Vue.js Components
22

3-
In order to equip a Ruby component with some JavaScript, we associate the Ruby component with a Vue.js JavaScript component. The Ruby component therefore needs to inherit from `Matestack::Ui::VueJsComponent`. Matestack will then render a HTML component tag with some special attributes and props around the response defined in the Ruby component. The Vue.js JavaScript component \(defined in a separate JavaScript file and managed via Webpacker\) will treat the response of the Ruby component as its template.
3+
In order to equip a Ruby component with some JavaScript, we associate the Ruby component with a Vue.js JavaScript component. The Ruby component therefore needs to inherit from `Matestack::Ui::VueJsComponent`. Matestack will then render a HTML component tag with some special attributes and props around the response defined in the Ruby component. The Vue.js JavaScript component (defined in a separate JavaScript file and managed via Webpacker) will treat the response of the Ruby component as its template.
44

55
## Structure, files and registry
66

@@ -62,6 +62,7 @@ The Vue.js JavaScript file needs to be imported by some kind of JavaScript packa
6262
For **Webpacker** it would look like this:
6363

6464
`javascript/packs/application.js`
65+
6566
```js
6667
import { createApp } from 'vue'
6768
import MatestackUiVueJs from 'matestack-ui-vuejs'
@@ -89,12 +90,11 @@ If setup correctly, Matestack will render the component to:
8990
</component>
9091
```
9192

92-
As you can see, the component tag is referencing the Vue.js JavaScript component via `is` and tells the JavaScript component that it should use the inner html \(coming from the `response` method\) as the template of the component.
93+
As you can see, the component tag is referencing the Vue.js JavaScript component via `is` and tells the JavaScript component that it should use the inner html (coming from the `response` method) as the template of the component.
9394

9495
`{{ vc.foo }}` will be evaluated to "bar" as soon as Vue.js has booted and mounted the component in the browser. `{{ foo }}` is not working!
9596

96-
The prefix `vc.` is short for `Vue Component` and is necessary for referencing the correct component scope. Within the JavaScript file, you still simply use `this.`
97-
The prefix is required since Vue 3 removed proper inline template support. Behind the scenes MatestackUiVueJs is using Vue's `default slot` mechanism in order to enable inline templates.
97+
The prefix `vc.` is short for `Vue Component` and is necessary for referencing the correct component scope. Within the JavaScript file, you still simply use `this.` The prefix is required since Vue 3 removed proper inline template support. Behind the scenes MatestackUiVueJs is using Vue's `default slot` mechanism in order to enable inline templates.
9898

9999
Matestack will inject JSON objects into the Vue.js JavaScript component through the `props` and `params` tags if either props or params are available. This data is injected once on initial server side rendering of the component's markup. See below, how you can pass in data to the Vue.js JavaScript component.
100100

@@ -185,8 +185,18 @@ As we're pretty much implementing pure Vue.js components, you can refer to the [
185185

186186
#### component $refs
187187

188-
- use `this.getRefs()` instead of `this.$refs`
188+
* use `this.getRefs()` instead of `this.$refs`
189+
* user `scoped_ref()` when applying refs to your componen template:
190+
191+
```ruby
192+
def response
193+
# ...
194+
div ref: "some-ref" # <-- not picked up by this.getRefs()
195+
# ...
196+
div "matestack-ui-core-ref": scoped_ref('some-ref')
197+
end
198+
```
189199

190200
#### component $el
191201

192-
- use `this.getElement()` instead of `this.$el`
202+
* use `this.getElement()` instead of `this.$el`

docs/custom-reactivity/matestacks-vue.js-apis-wip.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,16 @@ As we're pretty much implementing pure Vue.js components, you can refer to the [
6565
#### component $refs
6666

6767
* use `this.getRefs()` instead of `this.$refs`
68+
* use `scoped_ref()` when applying refs to your componen template:
69+
70+
```ruby
71+
def response
72+
# ...
73+
div ref: "some-ref" # <-- not picked up by this.getRefs()
74+
# ...
75+
div "matestack-ui-core-ref": scoped_ref('some-ref')
76+
end
77+
```
6878

6979
#### component $el
7080

docs/migrate-to-3.0.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,16 @@ end
383383
### component $refs
384384

385385
* use `this.getRefs()` instead of `this.$refs`
386+
* adjust ref specifications in your component templates:
386387

387-
\-> Search\&Replace
388+
```ruby
389+
def response
390+
# ...
391+
div ref: "some-ref" # <-- not picked up by this.getRefs()
392+
# ...
393+
div "matestack-ui-core-ref": scoped_ref('some-ref')
394+
end
395+
```
388396

389397
### component $el
390398

0 commit comments

Comments
 (0)