PHPackages                             protonemedia/laravel-blade-on-demand - 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. protonemedia/laravel-blade-on-demand

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

protonemedia/laravel-blade-on-demand
====================================

Compile Blade templates in memory

1.12.0(3mo ago)6244.4k↓19.6%7[1 PRs](https://github.com/protonemedia/laravel-blade-on-demand/pulls)MITPHPPHP ^8.5 || ^8.4 || ^8.3 || ^8.2CI passing

Since Mar 10Pushed 2mo ago3 watchersCompare

[ Source](https://github.com/protonemedia/laravel-blade-on-demand)[ Packagist](https://packagist.org/packages/protonemedia/laravel-blade-on-demand)[ Docs](https://github.com/protonemedia/laravel-blade-on-demand)[ GitHub Sponsors](https://github.com/pascalbaljet)[ RSS](/packages/protonemedia-laravel-blade-on-demand/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (23)Used By (0)

Laravel Blade On Demand
=======================

[](#laravel-blade-on-demand)

[![Latest Version on Packagist](https://camo.githubusercontent.com/77db9dead48f969748600b9d5ab40059240f6dd7cef129231c992c006a4f35d7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f70726f746f6e656d656469612f6c61726176656c2d626c6164652d6f6e2d64656d616e642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/protonemedia/laravel-blade-on-demand)[![run-tests](https://github.com/protonemedia/laravel-blade-on-demand/workflows/run-tests/badge.svg)](https://github.com/protonemedia/laravel-blade-on-demand/workflows/run-tests/badge.svg)[![Quality Score](https://camo.githubusercontent.com/a6e442a506abe6d9861dc478f24ad4bf1a68b8afbc4a6f6d7b3ec5445cb2eb4e/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f70726f746f6e656d656469612f6c61726176656c2d626c6164652d6f6e2d64656d616e642e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/protonemedia/laravel-blade-on-demand)[![Total Downloads](https://camo.githubusercontent.com/38696331e082881ce2aa8b4ab0483fef99df248655fee25d66e2e9ea4464290c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f70726f746f6e656d656469612f6c61726176656c2d626c6164652d6f6e2d64656d616e642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/protonemedia/laravel-blade-on-demand)

Laravel package to compile Blade templates in memory. Requires PHP 8.2 or higher, compatible with Laravel 11+.

Sponsor Us
----------

[](#sponsor-us)

[![](https://camo.githubusercontent.com/b5348f68e9a1a6ff90432d75a6692be1d604b3320ce1fcabd4b1ef29668053c4/68747470733a2f2f696e657274696175692e636f6d2f76697369742d636172642e6a7067)](https://inertiaui.com/inertia-table?utm_source=github&utm_campaign=laravel-blade-on-demand)

❤️ We proudly support the community by developing Laravel packages and giving them away for free. If this package saves you time or if you're relying on it professionally, please consider [sponsoring the maintenance and development](https://github.com/sponsors/pascalbaljet) and check out our latest premium package: [Inertia Table](https://inertiaui.com/inertia-table?utm_source=github&utm_campaign=laravel-blade-on-demand). Keeping track of issues and pull requests takes time, but we're happy to help!

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

[](#installation)

You can install the package via composer:

```
composer require protonemedia/laravel-blade-on-demand
```

Usage
-----

[](#usage)

### Render Blade template

[](#render-blade-template)

You can render any valid [Blade Template](https://laravel.com/docs/11.x/blade) by calling the `render` method on the `BladeOnDemand` facade. The method only takes two parameters, the template content and the data you want to pass to the template.

```
$output = BladeOnDemand::render('Hello {{ $name }}', ['name' => 'Protone Media']);

echo $output;

// "Hello Protone Media"
```

This is a just an example but you can use statements, components and other Blade features as well.

### Handle missing variables

[](#handle-missing-variables)

This feature prevents your render from failing whenever a variable is missing in your data array. By default it will fill the missing variable with the name of the variable itself. In this case `$name` is missing so the data array becomes `['name' => 'name']`;

```
$output = BladeOnDemand::fillMissingVariables()->render('Hello {{ $name }}', []);

echo $output;

// "Hello name"
```

You could also use this feature to preview a template without any data. Note that this might give unexpected results when using statements. You can also pass a `callable` to the `fillMissingVariables` method to customize the handling of missing variables:

```
$output = BladeOnDemand::fillMissingVariables(
    fn ($variable) => "_MISSING_{$variable}_MISSING_"
)->render('Hello {{ $name }}');

echo $output;

// "Hello _MISSING_name_MISSING_"
```

### Render Markdown Mail to HTML

[](#render-markdown-mail-to-html)

This feature can be used to render a mail as if you're using a [Markdown mailable](https://laravel.com/docs/11.x/mail#writing-markdown-messages).

```
$contents = implode(PHP_EOL, [
    '@component("mail::message")',
    '# Hello {{ $name }}',
    '@endcomponent',
]);

$output = BladeOnDemand::renderMarkdownMailToHtml($contents, ['name' => 'Protone Media']);

echo $output;

//
//
//
//     ...
//
//
//
//     ...
//

//
//     ...
//     Hello Protone Media
//     ...
//
//
//
```

You can optionally specify a theme, just like calling the `theme` method [on a Mailable](https://laravel.com/docs/11.x/notifications#customizing-the-components).

```
BladeOnDemand::theme('invoice')->renderMarkdownMailToHtml($contents, $data);
```

### Render Markdown Mail to text

[](#render-markdown-mail-to-text)

Similair feature as the above `renderMarkdownMailToHtml` method except it uses components from the `text` directory. You can read more about this feature in the [Laravel documentation](https://laravel.com/docs/11.x/mail#customizing-the-components).

```
$contents = implode(PHP_EOL, [
    '@component("mail::message")',
    '# Hello {{ $name }}',
    '@endcomponent',
]);

$output = BladeOnDemand::renderMarkdownMailToText($contents, ['name' => 'Protone Media']);

echo $output;

// [AppName](http://localhost)
//
// # Hello Protone Media
//
// © 2020 AppName. All rights reserved.
```

### Parse Maildown Mail

[](#parse-maildown-mail)

The `parseMarkdownMail` method is the same as the `renderMarkdownMailToText` method but it also parses the Markdown.

```
$contents = implode(PHP_EOL, [
    '@component("mail::message")',
    '# Hello {{ $name }}',
    '@endcomponent',
]);

$output = BladeOnDemand::parseMarkdownMail($contents, ['name' => 'Protone Media']);

echo $output;

// AppName
// Hello Protone Media
// © 2020 AppName. All rights reserved.
```

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Other Laravel packages
----------------------

[](#other-laravel-packages)

- [Inertia Modal](https://inertiaui.com/inertia-modal/docs/introduction): With Inertia Modal, you can easily open any route in a Modal or Slideover without having to change anything about your existing routes or controllers.

- [`Inertia Table`](https://inertiaui.com/inertia-table?utm_source=github&utm_campaign=laravel-blade-on-demand): The Ultimate Table for Inertia.js with built-in Query Builder.
- [`Laravel Cross Eloquent Search`](https://github.com/protonemedia/laravel-cross-eloquent-search): Laravel package to search through multiple Eloquent models.
- [`Laravel Eloquent Scope as Select`](https://github.com/protonemedia/laravel-eloquent-scope-as-select): Stop duplicating your Eloquent query scopes and constraints in PHP. This package lets you re-use your query scopes and constraints by adding them as a subquery.
- [`Laravel FFMpeg`](https://github.com/protonemedia/laravel-ffmpeg): This package provides an integration with FFmpeg for Laravel. The storage of the files is handled by Laravel's Filesystem.
- [`Laravel MinIO Testing Tools`](https://github.com/protonemedia/laravel-minio-testing-tools): Run your tests against a MinIO S3 server.
- [`Laravel Mixins`](https://github.com/protonemedia/laravel-mixins): A collection of Laravel goodies.
- [`Laravel Paddle`](https://github.com/protonemedia/laravel-paddle): Paddle.com API integration for Laravel with support for webhooks/events.
- [`Laravel Task Runner`](https://github.com/protonemedia/laravel-task-runner): Write Shell scripts like Blade Components and run them locally or on a remote server.
- [`Laravel Verify New Email`](https://github.com/protonemedia/laravel-verify-new-email): This package adds support for verifying new email addresses: when a user updates its email address, it won't replace the old one until the new one is verified.
- [`Laravel XSS Protection`](https://github.com/protonemedia/laravel-xss-protection): Laravel Middleware to protect your app against Cross-site scripting (XSS). It sanitizes request input, and it can sanatize Blade echo statements.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Pascal Baljet](https://github.com/protonemedia)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

61

—

FairBetter than 99% of packages

Maintenance84

Actively maintained with recent releases

Popularity42

Moderate usage in the ecosystem

Community15

Small or concentrated contributor base

Maturity83

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 90.9% 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 ~155 days

Recently: every ~194 days

Total

15

Last Release

90d ago

PHP version history (9 changes)1.0.0PHP ^7.2

1.3.0PHP ^7.3 || ^8.0

1.4.0PHP ^7.4 || ^8.0 || ^8.1

1.6.0PHP ^8.0 || ^8.1 || ^8.2

1.7.0PHP ^8.1 || ^8.2

1.8.0PHP ^8.1 || ^8.2 || ^8.3

1.9.0PHP ^8.3 || ^8.2

1.10.0PHP ^8.4 || ^8.3 || ^8.2

1.12.0PHP ^8.5 || ^8.4 || ^8.3 || ^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8403149?v=4)[Pascal Baljet](/maintainers/pascalbaljet)[@pascalbaljet](https://github.com/pascalbaljet)

---

Top Contributors

[![pascalbaljet](https://avatars.githubusercontent.com/u/8403149?v=4)](https://github.com/pascalbaljet "pascalbaljet (40 commits)")[![realpascalbotjet](https://avatars.githubusercontent.com/u/262015488?v=4)](https://github.com/realpascalbotjet "realpascalbotjet (3 commits)")[![amirsadeghi1](https://avatars.githubusercontent.com/u/26359326?v=4)](https://github.com/amirsadeghi1 "amirsadeghi1 (1 commits)")

---

Tags

laravellaravel-packageprotonemedialaravel-blade-on-demand

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/protonemedia-laravel-blade-on-demand/health.svg)

```
[![Health](https://phpackages.com/badges/protonemedia-laravel-blade-on-demand/health.svg)](https://phpackages.com/packages/protonemedia-laravel-blade-on-demand)
```

###  Alternatives

[rcrowe/twigbridge

Adds the power of Twig to Laravel

9105.9M50](/packages/rcrowe-twigbridge)[tightenco/jigsaw

Simple static sites with Laravel's Blade.

2.2k438.5k29](/packages/tightenco-jigsaw)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[moonshine/moonshine

Laravel administration panel

1.3k217.1k59](/packages/moonshine-moonshine)[livewire/blaze

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

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

TallStackUI is a powerful suite of Blade components that elevate your workflow of Livewire applications.

703141.0k7](/packages/tallstackui-tallstackui)

PHPackages © 2026

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