File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed
Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -791,6 +791,54 @@ public function test_nested_table_components(): void
791791 HTML, $ html );
792792 }
793793
794+ public function test_same_variable_can_be_passed_to_multiple_components (): void
795+ {
796+ $ this ->registerViewComponent (
797+ 'x-my-aside ' ,
798+ '<aside><x-template :foreach="$items as $item"><a href="$item[ \'id \']">{{$item[ \'label \']}}</a></x-template></aside> '
799+ );
800+
801+ $ this ->registerViewComponent (
802+ 'x-my-main ' ,
803+ '<main><x-template :foreach="$items as $item"><div>{{$item$item[ \'label \']}}</div></x-template></main> '
804+ );
805+
806+ $ this ->registerViewComponent (
807+ 'x-my-footer ' ,
808+ '<footer><x-template :foreach="$items as $item"><p>{{$item[ \'label \']}}</p></x-template></footer> '
809+ );
810+
811+ $ html = $ this ->render (
812+ view (
813+ <<<'HTML'
814+ <x-my-aside :items="$items" />
815+ <x-my-main :items="$items" />
816+ <x-my-footer :items="$items" />
817+ HTML,
818+ )->data (
819+ items: [
820+ ['id ' => '1 ' , 'label ' => 'Item 1 ' ],
821+ ['id ' => '2 ' , 'label ' => 'Item 2 ' ],
822+ ],
823+ )
824+ );
825+
826+ $ this ->assertSnippetsMatch (<<<HTML
827+ <aside>
828+ <a href="1">Item 1</a>
829+ <a href="2">Item 2</a>
830+ </aside>
831+ <main>
832+ <div>Item 1</div>
833+ <div>Item 2</div>
834+ </main>
835+ <footer>
836+ <p>Item 1</p>
837+ <p>Item 2</p>
838+ </footer>
839+ HTML , $ html );
840+ }
841+
794842 private function assertSnippetsMatch (string $ expected , string $ actual ): void
795843 {
796844 $ expected = str_replace ([PHP_EOL , ' ' ], '' , $ expected );
You can’t perform that action at this time.
0 commit comments