ekandreas / bladerunner

WordPress plugin for Laravel Blade templating DEPRECATED
http://bladerunner.elseif.se
12 stars 1 forks source link

How to extend blade templates? #22

Closed philippkuehn closed 8 years ago

philippkuehn commented 8 years ago

Hey,

in Laravel it's easy to extend a blade template like this:

Blade::extend(function($value)
{
    return preg_replace('/(\s*)@break(\s*)/', '$1<?php break; ?>$2', $value);
});

How can I do this with bladerunner? Blade::extend or Illuminate\Support\Facades\Blade::extend doesn't work for me.

ekandreas commented 8 years ago

No, it's just clean Blade right now without extensions to the syntax. I really want the plugin syntax to be clean but perhaps we could arrange some kind of way to add custom extensions?

ekandreas commented 8 years ago

v1.0.9 supports extensions via filter. Just waiting for some tests to run :-)

philippkuehn commented 8 years ago

That sounds great!

ekandreas commented 8 years ago

Released v1.0.9 with the support of extensions. Please take this as a experimental beta evaluation. I'm not really comfortable with using filters like explained in the readme. Perhaps we could make another type of interface to make it easier? But alright, let's try this!

philippkuehn commented 8 years ago

Filters are the WordPress-way to go. So I think that's pretty good. Thank you for your super fast update!

ekandreas commented 8 years ago

Perhaps the array added should contain arrays and not key/value. And perhaps with specific parameters:

$extensions[] = [
    'pattern'=>'...',
    'replace'=>'...',
];
hanspagel commented 8 years ago

Nice idea, this would improve the readability in my opinion. Especially with all the regex stuff, keys would become pretty unreadable otherwise.