Skip to content

Passing variables to blocks #982

Answered by pboivin
marlonbasten asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @marlonbasten,

I think you may be looking for the $data argument of renderBlocks().

You can use it to pass extra data to your blocks, like so :

@php
  $context = $page->getContext();
@endphp

{!! $page->renderBlocks(true, [], ['context' => $context]) !!}

Also, you may be interested in Laravel's View::share(), that would allow you to make certain variables globally accessible to all your Blade views (including custom blocks).

Hope this can help!

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by marlonbasten
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants