Closed BenRutlandWeb closed 2 years ago
The Macroable
trait is added to the factory and view, so you can use this macro:
<?php
use Radiate\View\View;
View::macro('markdown', function () {
return Str::markdown($this);
});
...and then...
<?php
use Radiate\Support\Facades\View;
$title = 'Hello World';
echo View::make('posts.hello-world', compact('title'))->markdown();
Or you can pass the rendered view to the markdown method.
The reason I won't add this is because it would no longer return the View
instance, rather than a string. If additional methods are added to the view class, they won't be available on this method - think for example of translations.
Is your feature request related to a problem? Please describe. I want to be able to write documents in markdown and convert them to HTML
Describe the solution you'd like A
markdown
method on theView
facade:This would get the view and parse it from markdown into HTML.
Describe alternatives you've considered Wrapping the view call in a
Str::markdown()
method.Additional context Adding the
Macroable
trait to the ViewFactory
would enable me to do this myself if the use case isn't great.