Skip the setup. Our team will have you taking orders in 24 hours. Get started →
Version notice: This documentation is for version 3, but the latest available version is version 4.
Customize

Partials

Introduction Rendering partials Passing parameters to partials #Introduction Partials include reusable Blade markup blocks that can be used anywhere on the...

Partials include reusable Blade markup blocks that can be used anywhere on the website. Partials are extremely useful for page sections that appear on multiple pages or layouts.

Partial files live in the /_partials subdirectory of a theme directory.

themes/
	your-theme/           <=== Theme directory
		_partials/         	  <=== Partials subdirectory
			sidebar.blade.php     <=== Partial template file

The Blade directive @partial('partial-name') renders a partial. The directive has a single parameter that is required - the name of the partial file without the .blade.php extension. You can specify the name of the subdirectory if you refer a partial from a subdirectory @partial('directory/partial-name'). You may use the @partial directive within a page, layout or other partials. An example of a page rendering a partial:

<div class="sidebar">
    @partial('sidebar')
</div>

You may pass variables to partials by defining them in the @partial directive after the partial name:

<div class="sidebar">
    @partial('sidebar', ['pages' => $pages])
</div>

You can access variables within the partial like any other markup variable:

<ul>
	@foreach($pages as $page)
		<li>{{ $page->name }}</li>
	@endforeach
</ul>

This section is incomplete. Please help to improve it.

Did this answer your question?

Your feedback helps us improve our help articles.

See a mistake? Edit this page on GitHub

Need more help?

Explore the help center, join the community, or get priority support from the TastyIgniter team.