I'd like to do something like this in my Blade pages:
<div class="accordion-content">
@mdsnippet('snippets/common/some-content-for-multiple-pages.md')
</div>
and then _snippets/common/some-content-for-multiple-pages.md contains:
## here's some content
which Hyde writes out to the output directory as:
<div class="accordion-content">
<h2>here's some content</h2>
</div>
Is this possible? It looks like we can add Blade in Markdown files:
https://hydephp.com/docs/1.x/advanced-markdown
But I'm wanting to do the reverse - Markdown in Blade files.
I'm the creator of HydePHP. This is indeed possible. While there is no built-in Blade directive for this (maybe we should add one!), you can easily accomplish this by simply using some PHP code to get a file's contents and compiling it to Markdown. HydePHP does include helpers in the Markdown
class.
Take this for example:
@extends('hyde::layouts.app')
@section('content')
<div class="prose">
<h1>{!! \Hyde\Markdown\Models\Markdown::render('**Markdown** in **Blade**!') !!}</h1>
{{ \Hyde\Markdown\Models\Markdown::fromFile(\Hyde\Hyde::path('resources/example-markdown.md')) }}
</div>
@endsection
This will take the file contents of the file in the resources/
directory (or whichever you choose) and compile the Markdown to HTML and put it in your Blade view!
You can of course also create your own Blade directive, or use a package. Though this is a great feature for us to include in HydePHP itself.