@@ -219,26 +219,19 @@ This gets rendered into HTML as shown below. Notice that the `@foo` from the com
219219To use * component instance scope slots* , first define slots within a static component:
220220
221221``` ruby
222- class Components ::Some ::Component < Matestack ::Ui ::StaticComponent
222+ class Components ::Other ::Component < Matestack ::Ui ::StaticComponent
223223
224224 def prepare
225- @foo = " foo from component"
225+ @foo = " foo from other component"
226226 end
227227
228228 def response
229229 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
242235 plain @foo
243236 end
244237 }
@@ -247,22 +240,29 @@ class Components::Some::Component < Matestack::Ui::StaticComponent
247240end
248241```
249242
250- And another component:
243+ and also in some component:
251244
252245``` ruby
253- class Components ::Other ::Component < Matestack ::Ui ::StaticComponent
246+ class Components ::Some ::Component < Matestack ::Ui ::StaticComponent
254247
255248 def prepare
256- @foo = " foo from other component"
249+ @foo = " foo from component"
257250 end
258251
259252 def response
260253 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
266266 plain @foo
267267 end
268268 }
@@ -271,7 +271,7 @@ class Components::Other::Component < Matestack::Ui::StaticComponent
271271end
272272```
273273
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:
275275
276276``` ruby
277277class Pages ::ExamplePage < Matestack ::Ui ::Page
@@ -367,7 +367,7 @@ Not a fancy example, but this is the result:
367367<div id =" div-on-page" >
368368 <div id =" my-component" >
369369 foo from page
370- </div >
370+ </div >
371371</div >
372372```
373373
0 commit comments