@@ -219,26 +219,19 @@ This gets rendered into HTML as shown below. Notice that the `@foo` from the com
219
219
To use * component instance scope slots* , first define slots within a static component:
220
220
221
221
``` ruby
222
- class Components ::Some ::Component < Matestack ::Ui ::StaticComponent
222
+ class Components ::Other ::Component < Matestack ::Ui ::StaticComponent
223
223
224
224
def prepare
225
- @foo = " foo from component"
225
+ @foo = " foo from other component"
226
226
end
227
227
228
228
def response
229
229
components {
230
- div id: " my-component" do
231
- custom_other_component slots: {
232
- my_slot_from_component: my_slot_from_component,
233
- my_slot_from_page: @options [:my_slot_from_page ]
234
- }
235
- end
236
- }
237
- end
238
-
239
- def my_slot_from_component
240
- slot {
241
- span id: " my-slot-from-component" do
230
+ div id: " my-other-component" do
231
+ slot @options [:slots ][:my_slot_from_component ]
232
+ br
233
+ slot @options [:slots ][:my_slot_from_page ]
234
+ br
242
235
plain @foo
243
236
end
244
237
}
@@ -247,22 +240,29 @@ class Components::Some::Component < Matestack::Ui::StaticComponent
247
240
end
248
241
```
249
242
250
- And another component:
243
+ and also in some component:
251
244
252
245
``` ruby
253
- class Components ::Other ::Component < Matestack ::Ui ::StaticComponent
246
+ class Components ::Some ::Component < Matestack ::Ui ::StaticComponent
254
247
255
248
def prepare
256
- @foo = " foo from other component"
249
+ @foo = " foo from component"
257
250
end
258
251
259
252
def response
260
253
components {
261
- div id: " my-other-component" do
262
- slot @options [:slots ][:my_slot_from_component ]
263
- br
264
- slot @options [:slots ][:my_slot_from_page ]
265
- br
254
+ div id: " my-component" do
255
+ custom_other_component slots: {
256
+ my_slot_from_component: my_slot_from_component,
257
+ my_slot_from_page: @options [:my_slot_from_page ]
258
+ }
259
+ end
260
+ }
261
+ end
262
+
263
+ def my_slot_from_component
264
+ slot {
265
+ span id: " my-slot-from-component" do
266
266
plain @foo
267
267
end
268
268
}
@@ -271,7 +271,7 @@ class Components::Other::Component < Matestack::Ui::StaticComponent
271
271
end
272
272
```
273
273
274
- Then, put both components to use on the example page:
274
+ Then, put both components (note that some component uses other component so that's how they're both in here) to use on the example page:
275
275
276
276
``` ruby
277
277
class Pages ::ExamplePage < Matestack ::Ui ::Page
@@ -367,7 +367,7 @@ Not a fancy example, but this is the result:
367
367
<div id =" div-on-page" >
368
368
<div id =" my-component" >
369
369
foo from page
370
- </div >
370
+ </div >
371
371
</div >
372
372
```
373
373
0 commit comments