You want to send blade template content to your server and compile them with markdown ?!
Sep 17, 2015
4
Level 17
Blade Minify Middleware
Hey All.
I'm integrating Graham Campbell's Laravel-Markdown package so that all of my pages and posts can be entered into my db in markdown format and then rendered correctly in views.
But it seems that the parser is overly sensitive to indentation, see this issue here:
The basic gist is, any html blocks that aren't aligned left will be enclosed in <pre> tags and just print to the screen.
This will work:
<div>
@yield('content')
</div>
While this will not:
<div>
@yield('content')
</div>
So my thought was to create a template minifier of sorts that would strip any whitespace to the left of each line, as a before middleware on all blade templates.
I've created a ViewMinify middleware:
namespace Acme\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Contracts\View\Factory;
class ViewMinify
{
/**
* The view factory implementation.
*
* @var \Illuminate\Contracts\View\Factory
*/
protected $view;
/**
* Require the view factory
*
* @param \Illuminate\Contracts\View\Factory $view
* @return void
*/
public function __construct(Factory $view)
{
$this->view = $view;
}
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle(Request $request, Closure $next)
{
// minify the template here
return $next($request);
}
}
But now I'm stuck :(
Please or to participate in this conversation.