PHPackages                             jeroen-g/blade-macro - 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. jeroen-g/blade-macro

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

jeroen-g/blade-macro
====================

Create small, file-specific, macros in Blade like Twig has.

1.1.0(2y ago)571MITPHPPHP 8.0.\*||8.1.\*||8.2.\*||8.3.\*

Since Jan 26Pushed 2y ago1 watchersCompare

[ Source](https://github.com/Jeroen-G/Blade-macro)[ Packagist](https://packagist.org/packages/jeroen-g/blade-macro)[ Docs](https://github.com/jeroen-g/blade-macro)[ RSS](/packages/jeroen-g-blade-macro/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (5)Versions (3)Used By (0)

Blade Macro
===========

[](#blade-macro)

[![Latest Version on Packagist](https://camo.githubusercontent.com/fbf4141ea814acde30235d369d07db0707a90244fc519233385aac7bc69179fe/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a65726f656e2d672f626c6164652d6d6163726f2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jeroen-g/blade-macro)

Have you as a Laravel developer ever looked at [Twig macros](https://twig.symfony.com/doc/3.x/tags/macro.html) with envy?

Maybe you want to reuse a specific element twice on the same page, but you don't want to have it (supported) as a Blade component. With a Blade macro, you can. Here is an example:

```
@macro(listItem)
 {{ $name }}
@endmacro

@if($conditionIsTrue)

        @foreach($listOne as $name)
            @showMacro(listItem, ['name' => $name])
        @endforeach

@else

        @foreach($listTwo as $name)
            @showMacro(listItem, ['name' => $name])
        @endforeach

@endif
```

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

[](#installation)

Via Composer

```
$ composer require jeroen-g/blade-macro
```

Usage
-----

[](#usage)

Define a macro with the Blade directives:

```
@macro(myMacroName)

@endMacro
```

Call the macro elsewhere *in the same Blade file* with the Blade directive or PHP helper:

```
@showMacro(myMacroName)
// or
{!! m('myMacroName') !!}
```

Do you want to use a macro in another Blade view? Use a [Blade component](https://laravel.com/docs/blade#components).

Change log
----------

[](#change-log)

Please see the [changelog](changelog.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [contributing.md](contributing.md) for details and a todolist.

Credits
-------

[](#credits)

- [Jeroen](https://github.com/jeroen-g)
- [All Contributors](../../contributors)

License
-------

[](#license)

MIT. Please see the [license file](license.md) for more information.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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 ~416 days

Total

2

Last Release

785d ago

PHP version history (2 changes)1.0.0PHP 8.0.\*||8.1.\*||8.2.\*

1.1.0PHP 8.0.\*||8.1.\*||8.2.\*||8.3.\*

### Community

Maintainers

![](https://www.gravatar.com/avatar/0d8700d69abe733de151f8cf49084e99ded7b9d34d7b0d1cd8f3825f5d925ff3?d=identicon)[JeroenG](/maintainers/JeroenG)

---

Top Contributors

[![Jeroen-G](https://avatars.githubusercontent.com/u/1116853?v=4)](https://github.com/Jeroen-G "Jeroen-G (3 commits)")

---

Tags

laraveltwigblademacro

###  Code Quality

TestsPHPUnit

Code StyleECS

### Embed Badge

![Health badge](/badges/jeroen-g-blade-macro/health.svg)

```
[![Health](https://phpackages.com/badges/jeroen-g-blade-macro/health.svg)](https://phpackages.com/packages/jeroen-g-blade-macro)
```

###  Alternatives

[robsontenorio/mary

Gorgeous UI components for Livewire powered by daisyUI and Tailwind

1.5k454.7k15](/packages/robsontenorio-mary)[hedronium/spaceless-blade

Adds the @spaceless tag to Blade. (works like in Twig)

32632.8k1](/packages/hedronium-spaceless-blade)[stijnvanouplines/blade-country-flags

A package to easily make use of country flags in your Laravel Blade views.

26307.2k6](/packages/stijnvanouplines-blade-country-flags)[technikermathe/blade-lucide-icons

A package to easily make use of Lucide icons in your Laravel Blade views.

18299.2k7](/packages/technikermathe-blade-lucide-icons)[saade/blade-iconsax

A package to easily make use of Iconsax in your Laravel Blade views.

21138.5k](/packages/saade-blade-iconsax)[mckenziearts/blade-untitledui-icons

A package to easily make use of UntitledUI icons in your Laravel Blade views.

16104.9k5](/packages/mckenziearts-blade-untitledui-icons)

PHPackages © 2026

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