Blurring the lines between Blade and Markdown
Alpha software warning ⚠️#
This package is currently a proof of concept, and is not even remotely ready for production use.
Installation#
You can install the package via Composer:
1composer require hyde/bladedown
Usage#
This package adds a new "Bladematter" page type using .blade.md
, which is a combination of Blade and Markdown. This allows you to use Blade directives in your Markdown files.
1--- 2name: World 3--- 4 5# Hello, {{ $name }}! 6 7<x-header image="media/my-image.png"> 8 <x-slot name="title"> 9 Lorem Ipsum10 </x-slot>11 12 Lorem ipsum dolor sit amet13</x-header>14 15## More stuff16 17Lorem ipsum dolor sit amet.18 19@include('related-posts')20 21@push('footer')22 <script src="https://example.com/script.js"></script>23@endpush
Supported components#
We currently support the following subset of components.
As you can see, dynamic features like conditionals and loops are not supported. This is because those kinds of things can quickly get complex, and it's more maintainable to keep that logic in dedicated component files. Instead, the idea with this package is that you can easily include those components, and pass in the data you need.
Echoing variables#
All front matter properties are available as variables in the Bladedown file.
1---2name: World3---4 5# Hello, {{ $name }}! <!-- World -->
Including components#
Classic templating syntax#
1@include('related-posts') 2 3@include('related-posts', ['limit' => 5]) 4 5@component('faq-item') 6 @slot('question') How do I get started? @endslot 7 @slot('answer') Check our detailed documentation for step-by-step instructions. @endslot 8@endcomponent 9 10@component('faq-item')11 @slot('question') Can I customize the appearance? @endslot12 @slot('answer') Yes, the styles are easily customizable to fit your design. @endslot13@endcomponent
Newer component syntax#
1<x-news-banner />2 3<x-news-banner message="New package released!" />4 5<x-feature-card image="media/feature-image.png">6 <x-slot name="title">Exciting Feature</x-slot>7 <p>This feature allows you to do incredible things!</p>8</x-feature-card>
Pushing to stacks#
The push directive allows you to push to any stack in your layout. Perfect if you need to add a script or style for a specific page.
1@push('header')2 ## My header3@endpush4 5@push('footer')6 <script>7 console.log('Hello, World!');8 </script>9@endpush
Note that only @push
is supported and not similar ones like @prepend
or conditional pushes.
Information#
Contributing#
Contributions are welcome. Please see the hydephp/develop monorepo for details.
Security Considerations#
Remember that this package by design allows you to execute any arbitrary PHP code, regardless of the default HydePHP Markdown security settings.
The package assumes that you trust the authors of the Bladedown files, and take the same care as you would with any other PHP file in your project.
Security Vulnerabilities#
Please review the security policy on how to report security vulnerabilities.
License#
The MIT License (MIT). Please see License File for more information.