PHPackages                             crhayes/blade-partials - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. crhayes/blade-partials

ActiveLibrary[Templating &amp; Views](/categories/templating)

crhayes/blade-partials
======================

1.1(11y ago)527.9k4[1 issues](https://github.com/crhayes/blade-partials/issues)[2 PRs](https://github.com/crhayes/blade-partials/pulls)PHPPHP &gt;=5.3.0

Since Feb 25Pushed 10y ago4 watchersCompare

[ Source](https://github.com/crhayes/blade-partials)[ Packagist](https://packagist.org/packages/crhayes/blade-partials)[ RSS](/packages/crhayes-blade-partials/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (2)Dependencies (1)Versions (4)Used By (0)

Blade Partials
==============

[](#blade-partials)

This package introduces the concept of partials (not includes) in blade templating. Think of it like inline @extends functionality within your views.

Partials allow you to extend a view and inject content into it, inline, within your views.

Why?
----

[](#why)

To make it easier to create reusable components. I often find myself repeating a lot of HTML boilerplate when using frameworks like Bootstrap or Foundation, and this package reduces that. Furthermore, if we ever need to change the markup we don't need to hunt down every instance in our code to do so (DRY).

This functionality can be achieved by using `@include`, but that can be annoying when your templates are broken down into a ton of tiny templates scattered about.

Installation
------------

[](#installation)

Begin by installing this package through Composer.

```
{
    "require": {
        "crhayes/blade-partials": "0.*"
    }
}
```

Next open up `app/config/app.php`, comment out the Illuminate View Service Provider, and add the one from this package:

```
'providers' => array(
    //'Illuminate\View\ViewServiceProvider',
    ...
    'Crhayes\BladePartials\ViewServiceProvider',
)
```

And that's it!

Creating a Partial
------------------

[](#creating-a-partial)

Partials start with the `@partial('path.to.view')` directive, which accepts the view you want the partial to extend from, and end with the `@endpartial` directive.

```
@partial('partials.panel')
    @block('title', 'This is the panel title')

    @block('body')
        This is the panel body.
    @endblock
@endpartial
```

Blocks within partials behave the same way as sections within templates. They capture a piece of data that will be rendered into the extended view.

Rendering a Partial
-------------------

[](#rendering-a-partial)

We use the `@render('block-to-render')` directive to render a block of content that was provided via the respective `@block` directive. Note that we can also provide a default value.

```

        @render('title', 'Default Title')

        @render('body', 'Default Body')

```

Full Example
------------

[](#full-example)

This example will include our partial HTML file. Notice that we can create as many instances of the partial as we like.

```
// index.blade.php
@extends('layouts.master')

@section('content')
    @partial('partials.panel')
        @block('title', 'This is the panel title')

        @block('body')
            This is the panel body.
        @endblock
    @endpartial

    @partial('partials.panel')
        @block('title', 'This is a second panel title')

        @block('body')
            And we will have different content in this body.
        @endblock
    @endpartial
@stop

// /partials/panel.blade.php

        @render('title')

        @render('body')

```

Nesting Partials
----------------

[](#nesting-partials)

You can also do some cool things by nesting partials. For example:

```
// index.blade.php
@extends('layouts.master')

@section('content')
    @partial('partials.danger-panel')
        @block('title', 'This is the panel title')

        @block('body')
            This is the panel body.
        @endblock
    @endpartial
@stop

// partials/danger-panel.blade.php
@partial('partials.panel')
    @block('type', 'danger')

    @block('title')
    	Danger! @render('title')
    @endblock
@endpartial

// partials/panel.blade.php

        @render('title')

        @render('body')

```

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity60

Established project with proven stability

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~68 days

Total

3

Last Release

4320d ago

Major Versions

0.5 → 1.02014-06-03

### Community

Maintainers

![](https://www.gravatar.com/avatar/a33aa17cbe106f08931893b31e3d2aeab0ce722c282521aaeedec03a84ebd244?d=identicon)[crhayes](/maintainers/crhayes)

### Embed Badge

![Health badge](/badges/crhayes-blade-partials/health.svg)

```
[![Health](https://phpackages.com/badges/crhayes-blade-partials/health.svg)](https://phpackages.com/packages/crhayes-blade-partials)
```

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M2.6k](/packages/craftcms-cms)[robsontenorio/mary

Gorgeous UI components for Livewire powered by daisyUI and Tailwind

1.5k454.7k15](/packages/robsontenorio-mary)[livewire/blaze

A tool for optimizing Blade component performance by folding them into parent templates

688221.3k17](/packages/livewire-blaze)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

44643.1k1](/packages/pressbooks-pressbooks)[rareloop/lumberjack-core

A powerful MVC framework for the modern WordPress developer. Write better, more expressive and easier to maintain code

42155.0k19](/packages/rareloop-lumberjack-core)[konekt/html

HTML and Form Builders for the Laravel Framework

24403.2k5](/packages/konekt-html)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
